如何使用引导程序对齐div和行

时间:2017-01-09 09:55:35

标签: css twitter-bootstrap-3 grid-system

我无法对齐嵌套行。见下图。在md和lg屏幕上,我有1行为9,3行为3. 9 + 3 = 12。在sm屏幕中,我希望第一行为12,其他3行为(4 + 4 + 4)。

https://s28.postimg.org/f0xa2380t/helpbootstrap.png

    <div class="container">         
<div class="row">
  <div class="col-md-9 col-sm-12">
    <div class="row ">  
        <div class="col-md-12 large">
        </div>
    </div>
  </div>
  <div class="col-md-3 col-sm-12">
    <div class="row ">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>          
  </div>  
</div>

    .small{ height:100px; border: 1px solid;} .large{ height:200px; border: 1px solid;  }

https://jsfiddle.net/proabid/qLg72vns/

4 个答案:

答案 0 :(得分:2)

你只需要摆脱第二个div中的行:

&#13;
&#13;
<div class="container">
  <div class="row">
    <div class="col-md-9 col-sm-12">
      <div class="row ">
        <div class="col-md-12 large">
        </div>
      </div>
    </div>
    <div class="col-md-3 col-sm-12">
      <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
        <div class="col-md-12 col-sm-4 small">
        </div>
        <div class="col-md-12 col-sm-4 small">
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

Example bootply

答案 1 :(得分:0)

这可以使用Boostrap v4

<div class="container">
 <div class="row">
   <div class="col-md-9 col-sm-12 large">
     <p>
       Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui     exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
     </p>
   </div>
  <div class="col-md-3 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
  <div class="col-md-3 offset-md-9 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedi qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
  <div class="col-md-3 offset-md-9 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
</div>

的jsfiddle

https://jsfiddle.net/qLg72vns/8/

答案 2 :(得分:0)

@Procode请使用示例文本检查以下代码:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
			<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
            	<p>ABCD</p>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
            	 <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
            		<p>ABCD</p>
                </div>
                <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
            		<p>ABCD</p>
                </div>
                <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
            		<p>ABCD</p>
                </div>
            </div>
</div>

答案 3 :(得分:0)

删除额外的行确实解决了我的问题。