tags:

views:

21

answers:

2

I have a tag cloud with different font sizes.

<div>
    <a style="font-size:15px;">tag1</a>
    <a style="font-size:10px;">tag1</a>
</div>

And it looks like this:

alt text

Now I need to wrap each tag into its own div:

    <style>
        .cloud {float:left}
        .tag {float:left}
    </style>
    <div class="cloud">
        <div class="tag"><a style="font-size:15px;">tag1</a></div>
        <div class="tag"><a style="font-size:10px;">tag1</a></div>
    </div>

Which puts them all over the place. How to make them look like on the first picture?

alt text

UPDATE: Here is how it looks if I set fixed height for the .tag: alt text

A: 

Perhaps increase the line-height or vertical padding of the smaller font-sizes. The reason it's happening is because the smaller ones are wrapping around the larger ones as designed in the specification, so by increasing the size of the area of the smaller elements, the wrapping should be prevented.

As an aside, is there any need to float the tags in the first place? Just putting them all in a row as normal in your first example would seem to have the same effect.

hollsk
If I remove float there will be 1 tag per line.
serg
Oh, ok, of course - my mistake. In that case try setting a fixed height to the .tag div which should equalise everything.
hollsk
I put screenshot for fixed height. It looks better but still needs something.
serg
Hm, yes - it is a bit awkward. Is there a particular reason for wrapping each href in a div? It might be easier to take a different approach.
hollsk
+1  A: 

Replace

.tag {float:left}

by

.tag {display: inline}

Or was there some other reason why you were floating all the tags?

mercator