Is there any solution without JS?
html
<div class="wrapper">
<div class="fix"></div>
</div>
css
.wrapper {
max-width: 500px;
border: 1px solid red;
height: 5500px;
position: relative;
}
.fix {
width: inherit;
height: 20px;
position:fixed;
background: black;
}
I cant add any other styles for .wrapper
except width: 100%;
.
I try with width: inherit
but it doesn't work for me because of I have parent div with only max-width. source
Here is JsFiddle Demo
width
of parent byinherit
value. – Deputy