可调整大小的三列背景图像/封面布局



背景封面和百分比宽度完成工作缩放和对齐案例的图像视口比 16/9 更水平。对于屏幕高度大于宽度0.5625的情况,外部布局部分开始吃中心。在这种情况下,最好从左边和右边裁剪,或者在顶部和底部添加空白条。

请提供您已知的最佳实践。非常感谢您的参与,和平,ayo。

<div class="bg">
</div>
<div class="column" id="column_left">
</div>
<div class="column" id="column_center">
</div>
<div class="column" id="column_right">
</div>

.css:

bg {
   position: relative;
   overflow: hidden;
   height: 100%;
   width: 100%;
   max-width: 1920px;
   background: url(images/1920/bg.png) no-repeat center 0 /cover;
}
.column {
   max-width: 100%;
   opacity: 0;
   display: block;
   -webkit-transition: opacity 0.5s ease-in-out;
   -moz-transition: opacity 0.5s ease-in-out;
   transition: opacity 0.5s ease-in-out;
   position: absolute;
   height: 100%;
   &:hover {
      opacity: 1;
      cursor: pointer;
   }
}
#column_left {
   float: left;
   left: 0;
   width: 38.85%;
   background: url(images/1920/left.png) no-repeat 0 0 /cover;
}
#column_center {
   float: left;
   left: 0;
   right: 0;
   margin-left: 26.17%;
   width: 44.69%;
   background: url(images/1920/center.png) no-repeat center 0 /cover;
}
#column_right {
   float: right;
   right: 0;
   width: 39.58%;
   background: url(images/1920/right.png) no-repeat 100% 0 /cover;
}
你能

澄清你想实现什么吗?据我所知,听起来您可能想从封面更改为背景大小的包含?

background: url(images/1920/left.png) no-repeat 0 0 /cover;

background: url(images/1920/left.png) no-repeat 0 0;
background-size: contain;

最新更新