如何使div占据第一空的空间

时间:2015-06-02 16:07:34

标签: html5 twitter-bootstrap css3

如何使帖子占据第一个空白区域:http://www.dodaj.rs/f/2g/kr/2TzaCg1J/dodaj.png

这是我的代码,但看起来不一样......

 <div class="container">
           <div class="row">
            <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2014/01/jquery-highlight-table-row-and-column.html" class="btn btn-warning btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&text=CSS3" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&text=CSS3" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&text=CSS3" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&text=CSS3" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&text=CSS3" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>

           <div class="col-sm-4 col-md-4">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/47A447/ffffff&text=jQuery" class="img-responsive" />
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br />
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/07/cool-social-sharing-button-using-css3.html" class="btn btn-success btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
    </div>
 </div>

这也是现场的样子: http://www.bootply.com/8K6VYbTlYZ

1 个答案:

答案 0 :(得分:0)

好的,首先你需要重新排列你的div和类。你的行应涵盖一切。您需要将行高与列高Bootply working example

相匹配

这是css:

.row-to-col{
    display:table;
}
.col-to-row{
     float: none;
    display: table-cell;
    vertical-align: top;
}
.top-buffer{
    margin-top: 20px;
 }

HTML

 <div class="container">
     <div class="row row-to-col">
           <div class="col-sm-4 col-md-4 col-to-row">
            <div class="col-sm-12 col-md-12">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/e67e22/ffffff&amp;text=HTML5" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2014/01/jquery-highlight-table-row-and-column.html" class="btn btn-warning btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-12 col-md-12 top-buffer">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&amp;text=CSS3" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
          </div>
          <div class="col-sm-4 col-md-4 col-to-row">
           <div class="col-sm-12 col-md-12">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&amp;text=CSS3" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
           <div class="col-sm-12 col-md-12 top-buffer">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&amp;text=CSS3" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
          <div class="col-sm-12 col-md-12 top-buffer">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&amp;text=CSS3" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
   </div>
<div class="col-sm-4 col-md-4 col-to-row">
           <div class="col-sm-12 col-md-12">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/2980b9/ffffff&amp;text=CSS3" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/11/share-social-media-round-buttons.html" class="btn btn-primary btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>

           <div class="col-sm-12 col-md-12 top-buffer">
               <div class="post">
                   <div class="post-img-content">
                       <img src="http://placehold.it/460x250/47A447/ffffff&amp;text=jQuery" class="img-responsive">
                       <span class="post-title"><b>Make a Image Blur Effects With</b><br>
                           <b>CSS3 Blur</b></span>
                   </div>
                   <div class="content">
                       <div class="author">
                           By <b>Bhaumik</b> |
                           <time datetime="2014-01-20">January 20th, 2014</time>
                       </div>
                       <div>
                           Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                           Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                           unknown printer took a galley of type and scrambled it to make a type specimen book.
                       </div>
                       <div>
                           <a href="http://www.jquery2dotnet.com/2013/07/cool-social-sharing-button-using-css3.html" class="btn btn-success btn-sm">Read more</a>
                       </div>
                   </div>
               </div>
           </div>
       </div>
   </div>
 </div>