Solved

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

Posted on 2014-03-16
9
806 Views
Last Modified: 2014-03-16
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 -

Chris
0
Comment
Question by:St_Aug_Beach_Bum
  • 5
  • 4
9 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39932841
Just give the toggler a left margin

margin-left:230px
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 39932908
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.

Chris
0
 
LVL 58

Expert Comment

by:Gary
ID: 39932931
Then wrap everything on the right in a div container

<div>
<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!
</div></div>

<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>
</div>

Open in new window

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:St_Aug_Beach_Bum
ID: 39932951
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.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 39932958
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...
0
 
LVL 58

Expert Comment

by:Gary
ID: 39932983
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.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 39933005
I've been experimenting and experimenting.

It seems like this:

display:inline-block;

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?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39933024
If you are setting a defined width then its easy enough, but how will that work if you have no advert.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 39933142
Seems to work ok without the ad too :)

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

Chris
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Send email using HTML and PHP in separate file 5 41
Getting selected value using Jquery 3 22
CSS question 4 27
Incorrect css styling in footer 3 6
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question