<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style>
.box {
width: 50%;
height: 500px;
margin: 200px auto;
background-color: pink;
display: flex;
align-items: center;
flex-direction: column;
}
.item {
padding: 10%;
background-color: #00A883;
border: 1px solid red;
box-sizing: border-box;
width: 20%;
position: relative;
}
.warp {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
</style>
<body>
<div class="box">
<div class="item">
<div class="warp">
<!--真正的内容区域-->
<div class="content">
aaa
</div>
</div>
</div>
</div>
</body>
</html>
实现盒子高度按自身宽度等比例
最新推荐文章于 2024-07-11 17:14:12 发布