bootstrap cols没有排在div的中心

时间:2017-09-20 11:56:09

标签: html css

我的问题很简单,我的Bootstrap cols没有排在div的中间。

看看我的代码:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width = device-width, initial-scale = 1">
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="bootstrap.css">
        <link rel="stylesheet" type="text/css" href="style.css">
        <style type="text/css"></style>
    </head>
    <body>
        <div id="boxes">
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                <div id="box1">
                    Hello
                 </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                <div id="box2">
                    World
               </div>
            </div>
         </div>
    </body>
</html>


#boxes {
    margin: 0 auto;
    width: 100%;    
    max-width: 1000px;
    height: 600px;
    background-color: rgba(79, 27, 184, 0.29);
}
#box1 {
    width: 400px;
    height: 260px;
    border-radius: 10px;
    background-color: rgba(37, 100, 165, 0.80);
    border: 1px solid rgba(37, 100, 165, 0.80);
    margin-top: 50px;
    text-align: center;
}

#box2 {
    width: 400px;
    height: 260px;
    border-radius: 10px;
    background-color: rgba(37, 100, 165, 0.80);
    border: 1px solid rgba(37, 100, 165, 0.80);
    margin-top: 50px;
    text-align: center;
}

我已将col-lg放在6上,这应该是每盒div的50%。但是这些盒子显然不在它们的中心位置。任何帮助都将不胜感激。感谢。

2 个答案:

答案 0 :(得分:1)

如果您在这样的方框2中更改边距,那么它正是您要找的吗?

SELECT b.tablespace_name,
       tbs_size SizeMb,
       a.free_space FreeMb,
       CAST(round(((tbs_size - a.free_space)/tbs_size)*100,2)AS VARCHAR(6)) || '%'
         PercentFull
FROM   (
         SELECT tablespace_name,
                round(SUM(bytes)/1024/1024 ,2) AS free_space
          FROM   dba_free_space
          GROUP BY tablespace_name
        ) a,
        (
          SELECT tablespace_name,
                 SUM(bytes)/1024/1024 AS tbs_size
          FROM   dba_data_files
          GROUP BY tablespace_name
          UNION
          SELECT tablespace_name,
                 SUM(bytes)/1024/1024 tbs_size
          FROM   dba_temp_files
          GROUP BY tablespace_name
        ) b
WHERE a.tablespace_name(+)=b.tablespace_name;
 AND round(((tbs_size - a.free_space)/tbs_size)*100,2) > 50

答案 1 :(得分:0)

如果您正在使用bootstrap 4,请使用.row fiddle

包裹您的代码

#boxes {
    margin: 0 auto;
    width: 100%;    
    max-width: 1000px;
    height: 600px;
    background-color: rgba(79, 27, 184, 0.29);
}
#box1 {
    width: 400px;
    height: 260px;
    border-radius: 10px;
    background-color: rgba(37, 100, 165, 0.80);
    border: 1px solid rgba(37, 100, 165, 0.80);
    margin-top: 50px;
    text-align: center;
}

#box2 {
    width: 400px;
    height: 260px;
    border-radius: 10px;
    background-color: rgba(37, 100, 165, 0.80);
    border: 1px solid rgba(37, 100, 165, 0.80);
    margin-top: 50px;
    text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<body>
        <div id="boxes" class="row">
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                <div id="box1">
                    Hello
                 </div>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                <div id="box2">
                    World
               </div>
            </div>
         </div>
    </body>