[英]How to get the child width to not exceed the parent's width when parents width did not exceed its max-width value?
The parent div's width did not exceed the value set in its max-width
property.父 div 的宽度没有超过其
max-width
属性中设置的值。 How to get child to inherit the actual width of the parent and not cause the parent to increase its width?如何让子继承父的实际宽度而不导致父增加宽度?
I'm sorry but I didn't really understand the question, but I think what you are searching for is this:对不起,我不太明白这个问题,但我想你正在寻找的是这个:
.parent-el { max-width: 100px; width: 50px; border: 3px solid black; }.child-el { height: 100px; width: 100%; background-color: red; }
<html> <div class="parent-el"> <div class="child-el"></div> </div> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.