首页 > 解决方案 > 由于某种原因无法看到border-top

问题描述

边框顶部被页面顶部截断??

我尝试设置 h2 元素的 margin-top ,但结果仍然相同。

body {
  font-family: 'Open Sans', sans-serif;
  height: auto;
  margin: 0;
  background: #222;
}

#heading-background {
  background: #55d6aa;
  height: 50px;
  color: rgba(255, 255, 255, 1);
}

h2 {
  color: #222;
  padding: 0 0 0 14px;
  margin: 10px 0 0 20px;
  font-size: 28px;
  letter-spacing: 0.5em;
  display: inline;
  border: 2px solid #222;
  border-radius: 8px;
}
<div id="heading">
  <div id="heading-background">
    <div id="heading-text">
      <h2>TODO</h2>
    </div>
  </div>
</div>

标签: htmlcss

解决方案


这将完成工作 h2 { display: inline-block; }


推荐阅读