Oam Psy
Oam Psy

Reputation: 8663

HTML Expandable Nav Menu

I have a simple'ish issue, i trying to create an expandable drown.. using jQuery toggle.

I can get the overall feature working, but for some reason my sub menu is over lapping the main.. I believe is has something to do with the attribute padding-top:70px;

I am trying to re-create the NAV menu found here: http://adidasdesignstudios.com/

HTML:

<header class="menu">
<div class="sub">
    <nav>
        <ul class="sub-options">
            <li>
                <div>
                    <a href="#all_crafted">1_</a>
                    <section><br>Check out product designs.</section>
                </div>
            </li>
            <li>
                <div>
                    <a href="#all_about">2_</a>
                    <section><br>Find out more about.</section>
                </div>
            </li>
            <li>
                <div>
                    <a href="#all_in">3_</a>
                    <section><br>Learn design.</section>
                </div>
            </li>
            <li>
                <div>
                    <a href="#all_jobs">4_</a>
                    <section><br>View current job opportunities.</section>
                </div>
            </li>
            <li>
                <div>
                    <a href="#all_cities">5_</a>
                    <section><br>See our locations.</section>
                </div>
            </li>
            <li>
                <div>
                    <a href="#all_academy">6_</a>
                    <section><br>Learn more.</section>
                </div>
            </li>
        </ul>
    </nav>
</div>
</header>

CSS:

.menu {

color:#515151;
height:70px;
left:0;
width:100%;
background-color:rgba(19,19,19,0.8);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#CC131313,endColorstr=#CC131313);
top:0;
position:fixed;
zoom:1;
margin:0 auto;
display:block;
padding-top:70px;


.sub {
background:#fff;
position:absolute;
z-index:2;
width:100%;
border-radius:3px;
/*box-shadow:0 2px 4px #ddd;*/
border:1px solid #ddd;
display:none;
/*padding:40px 0 3px;*/
}

jQuery:

$(".menu").hover(
    function(){$(".sub").slideToggle(400);},
    function(){$(".sub").hide();}
);

I think im close, but any help would be appreciated.

Upvotes: 0

Views: 1023

Answers (3)

veelen
veelen

Reputation: 1914

I'd fix it with css alone (nno jQuery): Example => jsfiddle

Also, you are missing an '}' in your code:

.menu {
        color:#515151;
        height:70px;
        left:0;
        width:100%;
        background-color:rgba(19, 19, 19, 0.8);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#CC131313, endColorstr=#CC131313);
        top:0;
        position:fixed;
        zoom:1;
        margin:0 auto;
        display:block;
        padding-top:70px;
    **}**
    .sub {
        background:#fff;
        position:absolute;
        z-index:2;
        width:100%;
        border-radius:3px;
        /*box-shadow:0 2px 4px #ddd;*/
        border:1px solid #ddd;
        display:none;
        /*padding:40px 0 3px;*/
    }

Upvotes: 3

service-paradis
service-paradis

Reputation: 3398

In your class .sub, you set its position to position:absolute but nowhere you specify a position.

Try to add top:100%; in your class .sub. This way, it will be right under your menu. So no more overlapping.

Upvotes: 0

luca
luca

Reputation: 137

May not be the perfect answer, but this works when I tried it:

.menu {
    color:#515151;
    height:70px;
    left:0;
    width:100%;
    background-color:rgba(19, 19, 19, 0.8);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#CC131313, endColorstr=#CC131313);
    top:0;
    position:fixed;
    zoom:1;
    margin:0 auto;
    display:block;
}
.sub {
    background:#fff;
    position:absolute;
    z-index:2;
    width:100%;
    border-radius:3px;
    /*box-shadow:0 2px 4px #ddd;*/
    border:1px solid #ddd;
    display:none;
    /*padding:40px 0 3px;*/
    top: 70px;
}

I just deleted the 'paddign-top: 70px' from .menu and added a 'top: 70px' to .sub

Upvotes: 0

Related Questions