通常我们都是这样写,但是达不到等比缩放,因为给了固定宽高;
.topRadian {
display: flex;
width: 100%;
height: 195px;
background: url("../../../assets/images/bg_footerRadian.png") no-repeat top center;
background-size: 100% 100%;
}
更牛逼的操作,才能达到等比缩放: 同过设置padding-top 达到占位给盒子一个高度:公式: padding-top = (高度 / 宽度)* 100 % ,在background-size: cover; 让其背景撑满盒子,
baackground-position: top center; 根据其图片显示位置,也可以解决IE 的兼容性问题;
.topRadian {
padding-top: 10.1%;
background: url("../../../assets/images/bg_footerRadian.png") no-repeat top center;
background-size: cover;
}