css div - div overlapping another instead of adjusting to available space

This may be a bit tricky, I'm not sure.

I am using a wordpress theme that has a toggle-div so that certain content can be hidden or opened by the user.

It works.

However, the div for the toggle bar overlaps other divs if used side by side.

I don't know if the solution is going to involve css or a fix in the javascript? I'm thinking probably the css.

It's hard to explain - but you can see a sample of the problem here: http://shoutkey.com/trip 

Fill free to view the source code, which contains the css.

Thanks for any help you can provide on this -

Who is Participating?
GaryConnect With a Mentor Commented:
If you are setting a defined width then its easy enough, but how will that work if you have no advert.
Just give the toggler a left margin

St_Aug_Beach_BumAuthor Commented:
Hi Gary,

Thank you. The problem is that if I do that, if the toggle is in a location where there is not a div to the left, it leaves a blank space to the left.

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Then wrap everything on the right in a div container

<p>The text seems to be in the correct place, it's just the 'bar' that stretches across and in front of the left floated div:<br><br></p>

<div style="" class="toggle  close"><h3 style="display: none;" class="toggle-head-open"> Spoiler</h3><h3 style="display: block;" class="toggle-head-close"> Spoiler</h3><div style="display: none;" class="toggle-content">
Whoa - here's a spoiler!

<p><br>If it was just me writing, I just wouldn't put the toggle next to an ad. But I have writers that won't think about it and just put it anywhere, so I need some kind of solution so this can be used without this issue cropping up.<br><br><br><br></p>

Open in new window

St_Aug_Beach_BumAuthor Commented:
I'm not trying to be a problem... but that doesn't work either - the toggle will be placed in different locations in different articles. So it needs to work (take up the available horizontal space without overlap) wherever it is used in the article.
St_Aug_Beach_BumAuthor Commented:
ie: sometimes there will be a div to the left, sometimes there won't be. It would need to work and look good either way...
Then its not really possible with css - you cannot tell an element to be 100% and float another element next to it.
When you float an element it is no longer part of the normal page flow.
St_Aug_Beach_BumAuthor Commented:
I've been experimenting and experimenting.

It seems like this:


added to .toggle works.

I have not tested it across browsers yet.

The only thing is that I have to manually set the width, otherwise it ends up squashed. I'd rather have it take up the space horizontally automatically, but I can live with setting a width.

What do you think?
St_Aug_Beach_BumAuthor Commented:
Seems to work ok without the ad too :)

I appreciate your time and help and will send points your way :)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.