Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap dropdown overlapping container div, rather than pushing it down

I've recently started working with Twitter Bootstrap and am finding it fairly intuitive except for one thing.

I'm currently building a site featuring a wrapper (class .sliderwrap) containing an image, which will ultimately be replaced with an image slider. The image/slider has overlaid h1 text which is positioned absolutely.

On smaller screen widths, my navigation menu turns into a dropdown. When the dropdown is open, it pushes down the image within .sliderwrap, but overlaps .sliderwrap itself and the absolutely positioned text rather than pushing it down. This obviously ruins the h1 text, which I'd like to travel down the page along with the image.

How do I make the dropdown push .sliderwrap itself down rather than overlapping some of it?

Here's the page I'm having the issue with. (excuse the styling of the dropdown itself, it's far from finished!)

like image 895
Emma W Avatar asked Oct 03 '22 08:10

Emma W


1 Answers

I'm thinking that the easiest solution for this will be that you need to clear your floats in the primary and secondary menu.

As you can see you have:

<div class="navbar navbar-static-top">...</div>

And you also have:

<div class="secondmenu">...</div>

The easiest way to clear these would be to put them inside a .row class or .row-fluid. I also suggest that you get into the habit of adding rows to your code when you can so these kinds of things clear.

Your code should end up looking like this:

<div class="row">
  <div class="navbar navbar-static-top">...</div>
  <div class="secondmenu">...</div>
</div>

Last but not least... your text is not positioned absolutely in relation to the slider div, but instead to the browser chrome, so you need to make your slider container have a position: relative so any elements set to position: absolute inside that container (in this case your h1) will be positioned absolutely according to it's parent container.

So set this in your styles as well:

.sliderwrap {
  position: relative;
}

That pretty much fixes your double menu so it clears the slider and the text. Let me know if this works for you and if you need any clarification on the answers, don't forget to upvote or accept the answer if it works! Cheers.

like image 101
sulfureous Avatar answered Oct 12 '22 17:10

sulfureous