<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
/* 绝对定位的元素会脱离标准文档流,
父级塌陷,解决办法是给父级加高度 */
.wrapper{
/* 去掉滚动条 */
overflow: hidden;
position: relative;
width: 100%;
height: 500px;
}
.box{
width: 1920px;
height: 500px;
/* margin+负外边距 */
position: absolute;
left: 50%;
margin-left: -960px;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="box">
<img src="./img/01.jpg" alt="">
</div>
</div>
</body>
</html>
bananer图居中
最新推荐文章于 2024-10-31 15:56:11 发布