参考airbnb和hitour,得到以下demo,可以将图片高度固定后,图片自适应(特别适用于全屏的banner)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.x{
    width:100%;
    height:700px;
}
.x div{
    background-repeat: no-repeat;
    background-size: 100% 100%;
    height: 100%;
    width: 100%;
    position: relative;
    background-position: center center;
    background-size: cover;
}
</style>
</head>
<body>
<div class="x">
    <div style="background-image:url(http://i1.sinaimg.cn/gm/j/i/2011-10-09/U1782P115T41D234876F1162DT20111009144235.jpg)"></div>
</div>
</body>
</html>

 

相关文章:

  • 2021-11-03
  • 2021-10-17
  • 2021-10-27
  • 2021-09-07
  • 2021-10-17
  • 2021-09-07
  • 2021-11-03
猜你喜欢
  • 2021-10-17
  • 2021-08-28
  • 2021-12-22
  • 2021-10-17
  • 2021-11-28
  • 2021-12-22
  • 2021-10-27
  • 2021-11-01
相关资源
相似解决方案