堆叠时Bootstrap网格系统重叠

时间:2014-10-02 06:21:14

标签: twitter-bootstrap grid

我尝试使用Bootstrap网格系统创建基本的4平方。当屏幕中等大小时,我希望它是一个四方形,填满页面,当屏幕很小时,4平方就会堆叠。

我认为我的工作正常但是当屏幕尺寸变小时,第2和第3个框重叠。对我做错了什么建议?

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>My Website</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/respond.min.js"></script>
    <style type="text/css">
         html, body, .container {
            height: 100%;
        }

        html {
            min-height: 100%;
        }
        .divGeneral{
            text-align: center;
            border: 2px solid black;
        }
        .row{
            height: 50%
        }

        #topL{
            min-height: 100%;
        }
        #topR{
            min-height: 100%;
        }
        #botL{
            min-height: 100%;
        }
        #botR{
            min-height: 100%;
        }

    </style>

</head>

<body>

    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="js/bootstrap.min.js"></script>

    <div class="container">
        <div class="row">
            <div class="col-md-6 divGeneral" id="topL">trend charts

            </div>
            <div class="col-md-6 divGeneral" id="topR">detail
            </div>
        </div>
        <div class="row">
            <div class="col-md-6 divGeneral" id="botL">refire
            </div>
            <div class="col-md-6 divGeneral" id="botR">ncr
            </div>
        </div>
    </div>  
</body>
</html>

2 个答案:

答案 0 :(得分:2)

删除以下最小高度和高度:

    html {
        min-height: 100%;
    }
    .row{
        height: 50%
    }

    #topL{
        min-height: 100%;
    }
    #topR{
        min-height: 100%;
    }
    #botL{
        min-height: 100%;
    }
    #botR{
        min-height: 100%;
    }

尝试类似的东西:

<div class="container">
    <div class="row">
        <div class="col-md-6 divGeneral" id="topL">trend charts
        </div>
        <div class="col-md-6 divGeneral" id="topR">detail
        </div>
        <div class="col-md-6 divGeneral" id="botL">refire
        </div>
        <div class="col-md-6 divGeneral" id="botR">ncr
        </div>
    </div>
</div>  

编辑:见评论

答案 1 :(得分:0)

试试此代码

<div class="container">
        <div class="row">
            <div class="col-xs-6 divGeneral" id="topL">trend charts

            </div>
            <div class="col-xs-6 divGeneral" id="topR">detail
            </div>
        </div>
        <div class="row">
            <div class="col-xs-6 divGeneral" id="botL">refire
            </div>
            <div class="col-xs-6 divGeneral" id="botR">ncr
            </div>
        </div>
    </div>