Inheriting width from Bootstrap container with a fixed child position

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 result

http://plnkr.co/edit/yVk15RqDqAac4H2eDJQe

+4
source share
1 answer

width. , , . ( Chrome, FF IE11.)

, .

PLUNKR

:

, (250px) . , (90%) div , - , .

:

+3

Source: https://habr.com/ru/post/1619070/


All Articles