首頁  >  文章  >  web前端  >  為什麼 Button 文字預設垂直居中,而 Div 文字卻不是?

為什麼 Button 文字預設垂直居中,而 Div 文字卻不是?

Susan Sarandon
Susan Sarandon原創
2024-10-26 12:06:02837瀏覽

Why is Button Text Vertically Centered by Default, but Div Text Isn't?

了解按鈕文字垂直對齊

考慮以下HTML 標記和CSS 樣式:

<code class="html"><button class="button">Some Text</button>
<div class="button">Some Text</div></code>
<code class="css">.button {
  background: darkgrey;
  height: 40px;
  border: 2px solid grey;
  width: 100%;
  box-sizing: border-box;
  font-size: 14px;
  font-family: helvetica;
  text-align: center;
  margin-bottom: 20px;
}</code>

應用這些樣式時,您注意到

以上是為什麼 Button 文字預設垂直居中,而 Div 文字卻不是?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

css html webkit for internal Property default this
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:為什麼相對定位元素中的絕對定位元素會從其直接父級繼承其位置?下一篇:為什麼相對定位元素中的絕對定位元素會從其直接父級繼承其位置?

相關文章

看更多