English 中文(简体)
HTML/CSS - 如何使 div 相适应
原标题:HTML/CSS - How to make div s fit each other
  • 时间:2012-05-26 11:07:23
  •  标签:
  • html
  • css

我试图使我的 divs 适合彼此 就像在pinterest.com上。 现在,我的 html/cs 是这样:

<div id="content">
    <div class="box">my content, which can be xx px heigh.</div>
    <div class="box">my content, which can be xx px heigh.</div>
    <div class="box">my content, which can be xx px heigh.</div>
</div>

#content{ float:left;width:1000px; }
.box{
  margin: 10px;
  padding: 5px;
  width: 220px;
  float: left;
}

.box可以是任何高度的邮戳。 所以我希望我的divs 适合, 无论它有多高。 就像 pinterest. com:-)

最佳回答
问题回答

以列为单位思考

ccs cs (千分数)

 <style type="text/ccs cs (千分数)">

  .container { display:block;width:100%; /* or whatever you are using */ }
  .col { display:block;float:left;width:25%; }
  .box { display:block; padding:10px;margin:10px;}
  .clear { display:block; clear:both;line-height:0;}


</style>

上加标记

<div class="container">

 <div class="col">

  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>

 </div>

 <div class="col">

  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>

 </div>

 <div class="col">

  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>

 </div>

 <div class="col">

  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>
  <div class="box">my content, which can be xx px heigh.</div>

 </div>

 <div class="clear"></div>

</div>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签