【发布时间】:2015-11-28 17:28:35
【问题描述】:
我试图让一个标题 div 从它的父级继承它的宽度。 标题 div 的位置是固定的。
但是,正如您在我在这里创建的简单 PLNKR 中看到的那样:
http://plnkr.co/edit/wxcvssALhjxtzc7J4w3V
它实际上比它的父元素宽,这很奇怪。
html 看起来像这样:
<div class="category-body">We are in the category-body
<div class="category-header">We are in the category-header</div>
</div>
CSS 看起来像这样:
.category-body {
margin-left: 17% !important;
width: 67%;
background-color: red;
height: 500px;
}
.category-header {
position: fixed;
top: 51px;
width: inherit;
background-color: green;
}
任何想法为什么会发生这种情况?当然,如何解决它?
【问题讨论】:
标签: css