【问题标题】:Making a bootstrap carousel's positioning fixed?固定引导轮播的定位?
【发布时间】:2014-08-22 05:41:59
【问题描述】:

我正试图让我的引导轮播在固定位置充当背景。在我的实际代码中,我将其设置为填满屏幕的全宽和全高,但它只停留在一个地方。我在包含轮播的部分的一个类中添加了“位置:固定”,因此它会浮动在前面,我打算将它索引到我的其余内容的后面,但它就完全消失了?

我在这个简化的例子中复制了这个问题:

http://jsfiddle.net/v9FMw/4/

HTML

<div class="fill bg-green">
    <div>content section (scroll down)</div>
</div>
<div class="fill bg-white">
    <div>content section (further x)</div>
</div>
<div class="fill bg-green fixed-section"> <!-- fixed section declared here -->
    <-- carousel code -->
</div>
<div class="fill bg-white">
    <div>content section</div>
</div>

CSS:

.fill {
    width: 100%;
    height: 100%;
    position: relative;
}

.fixed-section {
    position: fixed; /* controls fixed carousel positioning here */
}

【问题讨论】:

    标签: css twitter-bootstrap background carousel fixed


    【解决方案1】:

    你必须给容器top: 0

    .fixed-section {
        position: fixed;
        top: 0;
    }
    

    Updated Fiddle

    【讨论】:

    • 太棒了。我整天都在把头撞在墙上,想知道为什么当我可以让它在我所有的其他部分上工作时这不起作用,却错过了明显的哈哈哈!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2012-11-25
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    • 2014-01-05
    • 2016-01-31
    • 1970-01-01
    • 2021-03-18
    相关资源
    最近更新 更多