一张图超过了屏幕大小 如何自动将多出部分隐藏 只显示中间部分

1.让图片处理居中的位置,当分辨率变化后就会自动裁减两边的。

最好用 背景图片,eg:

<div class="boundary">

<div class="by_main">

</div>

</div>
.boundary {
width: 100%;
overflow: hidden;
margin: 0 auto;
}
.by_main{
background: url("../images/top.jpg") center center no-repeat;
height: 768px;
}


2.当背景是一整张图片,内容太多,出现滚动条又想让图片自动拉伸,自适应
<div class="frame"> </div>

.frame{
    background: url("../images/bg.jpg") center no-repeat;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-attachment:fixed;
    min-height: 100%;
}

posted @ 2017-11-10 17:38  以后。h  阅读(846)  评论(0编辑  收藏  举报