<style>
* {
padding: 0;
margin: 0;
}
.zoomImage {
background: url("head_bg.png") no-repeat;
width: 100%;
height: 0;
padding-bottom: 50%;
overflow: hidden;
background-position: center center;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<div class="zoomImage"></div>
</body>
效果图:
原理:这是因为在padding为百分比的时候,是根据他父层的宽度来进行计算的