views:

274

answers:

3

I have this gallery of thumbnails of youtube videos with their title under. http://skitch.com/subzane/bqgqw/demo

The problem I have is that when floating them they don't appear as I like, this because the height is variable. I've read a blog post a few weeks ago solving just that problem but I can't find it anywhere.

So I'm asking for the link to that blog post or the contents of it really :)

  • The thumbnails height do vary, I cannot set this to a fixed height.
  • The number of thumbs per row vary. I cannot set a fixed number.
  • no javasscript fixes. only css.

Thank you

+1  A: 

instead of floating divs, you can switch your thumbnails to lists (which is actually more semantically correct anyway.. )

For example:

<style type="text/css">

ul {
    list-type: none;
}

li {
    display: inline;
}
li img {
    vertical-align: top;
    margin-left: 5px;
    padding-bottom: 5px;
}

</style>

<div style="width: 280">
    <ul>
    <li><img src="th1.gif" /></li>
    <li><img src="th2.gif" /></li>
    <li><img src="th3.gif" /></li>
    <li><img src="th1.gif" /></li>
    <li><img src="th2.gif" /></li>
    <li><img src="th3.gif" /></li>
    <li><img src="th1.gif" /></li>
    <li><img src="th2.gif" /></li>
    <li><img src="th3.gif" /></li>
    <li><img src="th1.gif" /></li>
    <li><img src="th2.gif" /></li>
    </ul>
</div>

for further reference, visit http://www.alistapart.com/articles/practicalcss/

datacop
Problem with this is that I cannot know when a new row starts. It could be after 2 items or 20.
SubZane
Ok.. then what exactally is it that you're trying to do? I've created a simple test page that floats div wrapped images to the left in line (in a container) and they all appear in a column format. What am I missing?
datacop
I've modified my original answer to move away from floated divs, and instead use unordered lists.
datacop
I've attached a screen shot and I've written in detail what I need to do. I don't know how to explain it any further.
SubZane
Thanks for your time though
SubZane
A: 

How much is the height really going to vary? If it's not going to vary much then just set the height to that of the max?

For browsers that support inline-block:

Although here's a inline-block cross browser article

#thumbsWrapper div{display:inline-block;vertical-align:top;margin:20px;border:solid 1px #f00;width:180px;}

<div id="thumbsWrapper">
  <div style="height:180px;">
    <img src="thumbnail1.gif" />
  </div>
  <div style="height:240px;">
    <img src="thumbnail2.gif" />
  </div>
  <div style="height:210px;">
    <img src="thumbnail3.gif" />
  </div>
  <div style="height:100px;">
    <img src="thumbnail4.gif" />
  </div>
  <div style="height:300px;">
    <img src="thumbnail5.gif" />
  </div>
  <div style="height:100px;">
    <img src="thumbnail6.gif" />
  </div>
</div>
Steve Perks
Like I wrote in my question. The thumbnails height do vary, and I cannot set this to a fixed height. So this isn't a solution for my problem. Thanks for your time though
SubZane
A: 

OK. After more hours of googling I found what I was looking for.

http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

It's a use of display: inline-block that solves my problem.

SubZane