开发者

multi-container blueprint grid and drop down menu cut off because of it

i have a dropdown menu in my header (blueprint) container (I'm using superfish jquery/css plugin). I have a footer and main content container as well. (I have them so I can have backgrounds in each that fill the browser width). The problem is the drop down menu (the drop down parts) gets cut off so you can't see the submenu links when its container ends and the next starts. By not putting the drop down menu in a container, I can circumvent this but then the menu is not aligned well.

Is there a way I can use the blueprint container around my header and not get it cut off? or some css I could try to make it align with the grid? (I'm using a 960px wide grid--I tried copying all the related css but it still didn't align for some reason, so maybe I missed something)

I've included some possibly relevant css...I was reluctant since it's still kind of messy but I had reasons for all the divs, I think...:( (#menu was used I think to separate the sf-menu and other links on the nav bar, #nav_container is to style the bar, blueprint grids must be contained in a .container, and trying to keep the code in superfish.css separate from my own styling until i figure out what's going on--I'm also not sure which properties I actually need in much of the following css, as I followed some examples with no explanations) Also, I'm using compass/sass rails plugin with blueprint, so the end result may be more verbose than normal css...

body .container {
  width: 950px;
  margin: 0 auto;
  overflow: hidden;
  *zoom: 1;
}

#nav_container {
  height: 34px;
  width: 100%;
  line-height: 36px;
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0;
}

#nav_container ul a {
  display: block;
}

#nav_container ul li {
  float: left;
  position: relative;
  top: -1px;
}
#nav_container #menu {
  display: inline;
  float: left;
  margin-right: 0;
  width: 950px;
  margin: 0 auto;
}

* html #nav_container #menu {
  overflow-x: hidden;
}

#nav_container #menu .sf-menu {
  width: 950px;
  margin: 0;
  margin-right: 0;
  display: block;
  float: left;
}

/*superfish stuff, edited from superfish.css*/

/* line 8, ../../app/stylesheets/partials/_superfish.sass */
.sf-menu ul {
  position: absolute;
  top: -999em;
  width: 10em;
}
.sf-menu ul li {
  width: 100%;
}
.sf-menu ul:hover {
  visibility: inherit;
  /* fixes IE7 'sticky bug' */
}
.sf-menu li {
  float: left;
  position: relative;
  /* match top ul list item height */
}
.sf-menu li:hover ul, .sf-menu li.sfHover ul {
  left: 0;
  top: 3em;
  z-index: 2;
}
.sf-menu a {
  display: block;
  position: relative;
}
ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul {
  top: -999em;
}
ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul {
  left: 10.75em;
  /*adjust this if not using rounded corners etc */
  top: 0;
}
ul.sf-menu li开发者_StackOverflow社区 li:hover li ul, ul.sf-menu li li.sfHover li ul {
  top: -999em;
}
ul.sf-menu li li li:hover ul, ul.sf-menu li li li.sfHover ul {
  left: 10em;
  /* match ul width */
  top: 0;
}

/** DEMO SKIN ** */
.sf-menu {
  float: left;
  margin-bottom: 1em;
}

HTML:

<div id='headerbg'> #this is a wrapper so the header has a full width bg image, just has a background property
              some stuff here
              <div id='nav_container'> 
                <div class='container'> 
                  <div id='menu'> 
                    <ul class='sf-menu'> 
                      <li><a href="/">Home</a></li> 
                      <li><a href="/about">About</a></li> 
                      <li><a href="#">Account</a> 
                        <ul> 
                          <li><a href="#">Settings</a> </li>
                          <li><a href="#">Other link</a></li>
                        </ul> 
                      </li>
                    </ul>
                  </div> 
                </div> 
              </div> 
            </div>

So if I hover over Account in the main menu, there's a smidgen of a dropdown menu but Settings and Other link are cut off.


I think you have an overflow problem:

body .container {
  /*...*/
  overflow: hidden;
  /*...*/
}

The height of div.container will be the height of the inner <ul class="sf-menu"> plus a little bit for whatever padding/margins/... are going on inside .container. When you hover over one of the menu items to activate the Superfish/Suckerfish stuff the child will appear and be clipped by the overflow: hidden setting on .container.

Drop the overflow:hidden and your clipping problem should go away. If you're using overflow:hidden as a clear-fix then you'll have to clear your floats by hand with a <div style="clear: both;"></div> (or similar) in an appropriate place.


EDIT: Now that I've seen your code, I think I have a better idea what to do... see below:

I am almost positive that this is a z-index issue from combining the Superfish DDM with Blueprint.css.

If I'm correct, the solution is to add a very high z-index property to the nearest positioned ancestor of the dropdown navigation. In your case, add:

#nav_container { z-index:600; }

If that doesn't work, try making the direct ancestor positioned and giving it a z-index:

#menu { position:relative; z-index:600; }

Note: in your code, you only made the z-index 2... I would make it something waaaay higher like 600 or 4000 or 99999. It doesn't matter what number you choose, just as long as it is very large and you know that no other element would ever be given a higher z-index.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜