如何避免div与Bootstrap中的另一个固定div重叠?

时间:2014-07-16 12:09:16

标签: css css3 twitter-bootstrap twitter-bootstrap-3

    <html>
<head>
    <link href="hue.css" rel="stylesheet">
</head>
<body>
    <div class="content">

        <div class="column">
            <div class="form">
                <div class="form-nivel">
                    <label for="cfdiCreate:organizationRfc">RFC</label><label id="cfdiCreate:organizationRfc">XXXXXXXXXXXX</label>
                </div>
                <div class="form-nivel">
                    <label for="cfdiCreate:organizationTaxSystem">Regimen    fiscal</label><label id="cfdiCreate:organizationTaxSystem">Sueldos y salarios</label>
                </div>
                <div class="form-nivel">
                    <label for="cfdiCreate:organizationTaxAddress">Domicilio  fiscal</label><label id="cfdiCreate:organizationTaxAddress">XXXXXX Colonia Tecnológico  Monterrey,Nuevo León,México.C.P.XXXXXX</label>
                </div>
                <div class="form-nivel">
                    <label for="cfdiCreate:organizationExpeditionPlace">Lugar de  expedición</label><label id="cfdiCreate:organizationExpeditionPlace">Suc.1 Chiapas,México.     </label>
                </div>
            </div>
        </div>
        <div class="column secondary">
            <!--?xml version="1.0" encoding="UTF-8"?-->
        </div>
</body>
</html>

position :fixed使div修复,但当我们向下滚动时,它与其他div重叠。如何将此行固定在顶部,并且每当我们向下滚动时,不要让div与另一个div重叠。

1 个答案:

答案 0 :(得分:1)

如果我想猜你想要什么(一个固定的顶部栏位于页面下方的内容/ div之上),就像这样:

.column {
    position: fixed;
    top: 0;
    z-index: 10;
}

.secondary {
    position: relative;
    z-index: 5;
}

使用示例查看此CodePen,我已将代码缩短为仅包含必要位。