I am trying to make the div header inherit its width from the parent. The title of the title position: fixed. The parent is contained inside the bootstrap container.
However, as you see in the code I created, it does not inherit the width of its parent correctly - it adds some extra width somewhere.
This is very annoying! Any idea how to fix this?
.category-body {
margin-left: 17% !important;
width: 67%;
background-color: red;
height: 500px;
}
.category-header {
position: fixed;
top: 51px;
width: inherit;
background-color: green;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="category-body">We are in the category-body
<div class="category-header">We are in the category-header</div>
</div>
</div>
Run codeHide resulthttp://plnkr.co/edit/yVk15RqDqAac4H2eDJQe
source
share