首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >超大-全屏背景-只在一半上?

超大-全屏背景-只在一半上?
EN

Stack Overflow用户
提问于 2015-01-12 20:15:25
回答 3查看 398关注 0票数 1

我想使用超大全屏背景Supersized

但我想有滑块只在网站的右半部分,在左边我想有我的内容。当我滚动时,内容应该会移动,而背景会保持不变。就像这里:example site

有谁有主意吗?

编辑:好的,我知道了,但是我怎么才能让图像响应呢?有可能吗?

EN

回答 3

Stack Overflow用户

发布于 2015-01-12 20:23:23

代码语言:javascript
运行
复制
.supersized {position:fixed;width:50% top:0;bottom:0;}
票数 0
EN

Stack Overflow用户

发布于 2015-01-12 20:23:35

如果你使用dev工具浏览,你会看到:

代码语言:javascript
运行
复制
#supersized {
    position: fixed;
    right: 0;
    top: 0;
    overflow: hidden;
    z-index: -999;
    height: 100%;
    width: 50%;
}
票数 0
EN

Stack Overflow用户

发布于 2015-01-12 21:16:43

包含内容的DIV应该有一个溢出卷轴:

代码语言:javascript
运行
复制
<style>
    .content{
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 50%;
        overflow: scroll;
    }
    .the-bg{
        background-image: ...;
        background-size: cover;
        position: absolute;
        left: 50%;
        top: 0;
        bottom: 0;
        width: 50%;
    }
</style>

<div class="content">lorem ipsum</div>
<div class="the-bg"></div>

或者,你可以把右边的放在固定的位置:

代码语言:javascript
运行
复制
<style>
    .content{
        float: left;
        width: 50%;
    }
    .the-bg{
        background-image: ...;
        background-size: cover;
        position: fixed;
        left: 50%;
        top: 0;
        bottom: 0;
        width: 50%;
    }
</style>

<div class="content">lorem ipsum</div>
<div class="the-bg"></div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27901803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档