CSS set width to parentNode's width
Is there a way in CSS to set the width of any element to equal the width of its parentNode? I tried 'inherit' - sounds logic - but 开发者_JS百科it didn't work.
Thanks in advance.
width: 100%;
This means 100% of the parent element's width.
Note that it might not work if the element has the display property set to something different to "block", and in a few other cases.
If you try it on 2 nested divs, it'll work.
Depending on what element it is, setting the CSS property display: block
will usually make it automatically fill all possible width, aka stretch to its maximum without overflowing on padding or borders.
精彩评论