Extra whitespace in expanding div

Hi All
I have (reluctantly as I don’t fully understand all the code) used Javascript from www.dhtmlgoodies.com to make an expanding faq section.

This works well see www.swiftecology.co.uk/faq.php

I have (I think) used the same device on the “about” page: www.swiftecology.co.uk/about.php but I’m getting white space after the text once opened up - it disappears when I open another section though then that section has the whitespace.

Perhaps there’s a missing line of code or an errant full stop but I can’t see it.

Any clues?

Thanks in advance

Mandy

Hi,

This is a css issue and your ‘clearfl’ rule is causing the problem.

Because your left column doesn’t create a new block formatting context then any clear properties you apply to elements in that div will have to clear any floats earlier in the html which in this case means the ‘clearfl’ will clear your right floated column. If you run your code you will see that is exactly what happens and the next item is below the right floated columns bottom.

These days you should not need extra elements to clear floats anyway but that is a question for another post.:slight_smile:

The easiest solution to your problem is to float the left column as well. You already have given it a width so you may as well float it also and then any clear properties will be confined to inside that left column as floats create new block formatting contexts and the clear will only apply inside that block.

.leftcol {float:left}

Thanks PaulOB both for explaining it so well AND giving me a solution.

Floats do seem like a convoluted way of aligning things but as you say - for another post.

I can rest easy now.

Mandy

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.