Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am not an native English speaker. It could be just a simple mistake. I am a novice in web designing. I want to make a drop down navigation menu which is on a integrated centering position.

share|improve this question
    
provide fiddle or link so i can understand what you are looking for –  Dhaval Panchal Jul 31 at 6:54
2  
Your English is fine. It would be good to see what code you already have or provide a link to an example to what you are trying to do. But have you tied text-align center –  CodeWizard Jul 31 at 6:54
    
I can't post my html and css code. If i post my code You solve my problem –  user3567569 Jul 31 at 7:08

2 Answers 2

up vote 0 down vote accepted

Demo

html

<div class="container landing_page">
    <div class="menu-wrapper">  
        <a href="#" class="menu-link">Menu<span class="ico-caret-down right" aria-hidden="true"></span>
        </a>
        <nav id="menu" role="navigation">
            <div class="menu">
                <ul class="menu">
                    <li>
                        <a href="#">Milk</a>
                    </li>
                    <li class="has-subnav"> 
                        <a>Egg</a>
                        <ul class="sub-menu">
                            <li>    
                                <a href="#" target="_blank">Sub Menu</a>
                            </li>
                            <li>    
                                <a href="#">Sub Menu</a>
                            </li>
                            <li>    
                                <a href="#">Sub Menu</a>
                            </li>
                        </ul>
                    </li>
                    <li>    
                        <a href="#">Cheese</a>                       
                    </li>
                    <li>    
                        <a href="#">Vegetable</a>
                    </li>
                    <li>    
                        <a href="#">Fruit</a>
                    </li>
                </ul>
            </div>
        </nav>
    </div>
</div>

css

html {
    height:100%
}
*, :after, :before {
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    box-sizing:border-box;
    padding:0;
    margin:0
}
.clearfix:after {
    content:"";
    display:table;
    clear:both
}
body {
    font-family:Calibri, Lato, sans-serif;
    font-weight:300;
    font-size:15px;
    -webkit-font-smoothing:antialiased
}
a {
    text-decoration:none;
    color:#000
}
nav {
    display:block
}
.right {
    float:right;
    margin-left:1em
}
.ico-caret-down:before {
    content:"==";
    font-weight:700
}
.menu-wrapper {
    position:fixed;
    left:0;
    right:0;
    margin:auto;
    width:100%;
    z-index:9999;
    font-size:1.1em
}
.menu-wrapper .menu {
    margin:0;
    padding-left:0;
    list-style:none;
    text-align:center
}
.menu-wrapper .menu>li {
    position:relative;
    display:inline-block;
    margin:0 -2px;
    background:rgba(0, 0, 0, .4)
}
.menu-wrapper a.menu-link {
    display:none;
    padding:.7em 0;
    background:rgba(0, 0, 0, .9)
}
.menu-wrapper a {
    display:block;
    position:relative;
    padding:10px 26px;
    line-height:1.3em;
    text-decoration:none;
    color:#000;
    background:rgba(0, 0, 0, .4);
}
.menu-wrapper a:hover {
    color:#fff;
    background:rgba(0, 0, 0, .4);
    cursor:pointer
}
.menu-wrapper .sub-menu {
    box-sizing:border-box;
    -moz-box-sizing:border-box;
    position:absolute;
    max-height:0;
    overflow:hidden;
    list-style:none outside none;
    text-align:center;
    text-transform:none
}
.menu-wrapper .sub-menu li {
    display:block
}
.menu-wrapper .sub-menu a {
    margin:0;
    padding:10px 16px;
    white-space:nowrap;
    border:none
}
.menu-wrapper .sub-menu a:hover {
    background:rgba(0, 0, 0, .4)
}
.menu-wrapper li:hover .sub-menu {
    margin-left:-13px;
    background:rgba(255, 255, 255, .8);
    max-height:30em;
    transition:max-height .5s
}
@media screen and (max-width: 600px) {
    .deco {
        width: 90px;
        padding-top: 20px;
    }
    .decoImg {
        margin: auto;
        width: 90px;
    }
    .rotate {
        bottom: 10px;
        text-shadow: none;
        font-size: 1.5em;
    }
    .js .menu-wrapper nav[role=navigation] {
        overflow: hidden;
        max-height: 0em;
    }
    .js .menu-wrapper nav[role=navigation].active {
        max-height: 30em;
        transition: max-height 0.5s ease-out;
    }
    .menu-wrapper {
        /* unhide the 2nd level */
        /* styling the toggle menu */
        /* arrow to indicate that we have subnav*/
    }
    .menu-wrapper a.menu-link {
        display: block;
        width: auto;
        color: #fff;
        padding-right: 15px;
        padding-left: 10px;
        border: none;
        margin: 0;
        background:rgba(0, 0, 0, 0.6);
    }
    .menu-wrapper a.menu-link:hover {
        background:rgba(0, 0, 0, 0.4);
    }
    .menu-wrapper .menu .menu {
        padding-bottom: 5px;
    }
    .menu-wrapper .menu li {
        display: block;
        border: none;
    }
    .menu-wrapper .menu > li {
        padding: 0px;
        border-top: 1px solid #aaa;
    }
    .menu-wrapper .menu a {
        padding: 0.5em 0;
        margin: 0px;
        border: none;
    }
    .menu-wrapper .menu a:hover {
        background: rgba(0, 0, 0, 0.4);
    }
    .menu-wrapper .menu .rightalign {
        float: none;
    }
    .menu-wrapper li:hover .sub-menu {
        max-height: 0em;
        transition: none;
    }
    .menu-wrapper .sub-menu {
        background: none;
        margin-left: 0px;
        margin-top: 1px;
        display: block;
        width: 100%;
    }
    .menu-wrapper .sub-menu li, .menu-wrapper .sub-menu li a {
        margin: 0;
        display: block;
        width: 100%;
    }
    .menu-wrapper .sub-menu a {
        padding-left: 0.8em;
    }
    .menu-wrapper .menu .has-subnav {
        position: relative;
    }
    .menu-wrapper li .sub-menu.active {
        max-height: 30em;
        overflow: visible;
        position: relative;
        z-index: 9;
        transition: max-height 0.5s ease-out;
    }
    .menu-wrapper .toggle-link {
        height: 38px;
        width: 58px;
        display: block;
        position: absolute;
        right: 0px;
        z-index: 200;
        font-size: 0em;
        cursor: pointer;
        font-weight: bold;
        line-height: 1;
    }
    .menu-wrapper .toggle-link:hover {
        transition: all 0.2s;
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
    }
    .menu-wrapper .menu .has-subnav > .toggle-link:after {
        content:"+";
        position: absolute;
        width: 50px;
        top: 50%;
        margin-top: -15px;
        bottom: 50%;
        right: 4px;
        font-size: 28px;
    }
    .menu-wrapper .menu .has-subnav > .toggle-link.active:after {
        content:"-";
        margin-top: -18px;
    }
}

js

$(document).ready(function () {
    $('body').addClass('js');
    var $menu = $('#menu'),
        $menulink = $('.menu-link'),
        $menuTrigger = $('.has-subnav > a');

    $menulink.click(function (e) {
        e.preventDefault();
        $menulink.toggleClass('active');
        $menu.toggleClass('active');
    });

    var add_toggle_links = function () {
        if ($('.menu-link').is(":visible")) {
            if ($(".toggle-link").length > 0) {} else {
                $('.has-subnav > a').before('<span class="toggle-link"> Open submenu </span>');
                $('.toggle-link').click(function (e) {
                    var $this = $(this);
                    $this.toggleClass('active').siblings('ul').toggleClass('active');
                });
            }
        } else {
            $('.toggle-link').empty();
        }
    }
    add_toggle_links();
    $(window).bind("resize", add_toggle_links);

});
share|improve this answer
    
Here I have changed my answet as according to your fiddle. –  4dgaurav Jul 31 at 8:26
    
    
please check my code jsfiddle.net/udayancht/9BP2f –  user3567569 Jul 31 at 9:07
    
so whats the issue? –  4dgaurav Jul 31 at 9:08
    
#navcontainer ul ul{position:absolute;left:0;top:46px;z-index:10;width:100%;display:none;backgrou‌​nd:red;} width:100% not work properly –  user3567569 Jul 31 at 9:12
Please check this [fiddle][1].

Is this what your trying to tell. If yes adding space is the only hack i know

  [1]: http://jsfiddle.net/Me5rF/
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.