开发者

How to achieve float: top in CSS/HTML

开发者 https://www.devze.com 2023-03-08 02:01 出处:网络
If you can read the Headings ... one\'s called JWT, the other Alela Diane.. how do I get \"Alela Diane\" to fill up the space between them ( no puns intended )

If you can read the Headings ... one's called JWT, the other Alela Diane.. how do I get "Alela Diane" to fill up the space between them ( no puns intended )

The CSS property for these div's is set to display: inline-block.

How to achieve float: top in CSS/HTML

The HTML - >

<div id="shastra_display">

<div class="shastra_post">
  There are multiple div's like this containing the Alela Diane's and JWT's etc.
</div> 

</div>

The CSS - >

#shastra_display
{
    width: 880px;
}

#shastra_display d开发者_如何学Goiv
{
    display: inline-block;
    vertical-align: text-top;
}

.shastra_post
{
    width: 270px;
    background-color: light-grey;
}


Is it always going to be just two columns? – thirtydot

It's two columns because the width of the parent box allows only two to fit. – Zach

So, the number of columns changes depending on the browser width.

That means you can't "cheat" and do it like this (as suggested by @Stefy):

  • http://jsbin.com/atimu4

Other than a fixed number of columns, CSS can't do it. See this answer for a comparision of the ideas:

  • CSS Floating Divs At Variable Heights

You will have to use JavaScript. There's already a convienient jQuery plugin: jQuery Masonry

Some interesting demos:

  • http://masonry.desandro.com/demos/animating-jquery.html
  • http://masonry.desandro.com/demos/adding-items.html


You should probably use a 2-column template in order to display the items properly.

0

精彩评论

暂无评论...
验证码 换一张
取 消