在开发的过程中想要确保背景图片等比例,该怎么做,就是确保盒子等比例
关键代码:
CSS aspect-ratio: 958 / 1000; /* 设置宽高比为 16:9 */
完整代码:
CSS.pop-main {
display: inline-block;
width: 95vw; /* 可以根据需要调整 */
aspect-ratio: 958 / 1000; /* 设置宽高比为 16:9 */
background-image: url("https://oss.turingsenseai.com/1727343336136121609.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover; /* 确保图像填充盒子 */
}