首页  >  文章  >  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
上一篇:Why Does an Absolutely Positioned Element Within a Relatively Positioned Element Inherit Its Position from Its Immediate Parent?下一篇:How to Effectively Style the `mat-select` Panel in Angular Material?

相关文章

查看更多