记录一下-纯 CSS实现根据元素已知的宽度设置高度以及注意事项


核心知识点:

实例:

// HTML



// CSS
.box {
position:relative;
width:40%;
height:0;
font-size:0;
line-height:0;
padding:40% 0 0;
}
img {
position: absolute;
width: 100%;
height: 100%;
}

原文链接:https://blog.csdn.net/DeepLies/article/details/77267823