html - Width inherit on fixed div doesn't work -
first, here example of have. https://jsfiddle.net/1xyofup5/
html code :
<div> <div class="container"> <div> <div> content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content </div> <div class="fixed"> other content </div> </div> </div> </div>
css code :
.container { width: 350px; height: 100%; position: absolute; } .container > div { overflow-y: auto; overflow-x: hidden; height: calc(100% - 50px); border: 1px solid red; } .container > div > .fixed { padding: 10px; position: fixed; bottom: 0; background-color: white; border: 1px solid green; width: inherit; }
i can't change html structure , can edit .container > div
, .container > div > .fixed
rules.
how can make fixed div fit width of parent ? inherit
doesn't work.
thanks !
w3schools.com on inherit
property:
the inherit keyword specifies property should inherit value parent element.
and mdn:
the inherit css-value causes element specified take computed value of property parent element. allowed on every css property.
for inherited properties, reinforces default behavior, , needed override rule. non-inherited properties, specifies behavior typically makes relatively little sense , may consider using initial instead, or unset on property.
inheritance parent element in document tree, when parent element not containing block.
in case, inherited value fixed
not want because its' direct parent (.container > div
) doesn't have a width
set, , gets default value of auto
.
i see 2 simple solutions:
option 1
inherit width throughout children. add this:
.container > div { width: inherit; }
that way, width of container
inherited twice down fixed
element.
option 2
give .container > div
its' own width:
.container > div { width: 300px; }
Comments
Post a Comment