Question

I have this submenu and I would like it so that when the dropdown menu is out it has a width of 100% and covers the whole page. At the moment if I change the width to 100% it just makes it the same width as the main menu.

This is my current HTML:

<header>
<div class="header">
    <div class="nav">
        <ul>
            <li>    <a href="services.html">Services</a>

                <ul class="sub">    <a href="services.html#branddesign">
                            <li><img class="imgcenter" src="images/Brand-Design-Circle-Blue.png" width="100px" />
                                <br>
                                Brand Design
                            </li></a>
<a href="services.html#brandonline">
                            <li><img class="imgcenter" src="images/Brand-Online-Circle-Blue.png" width="100px" />
                                <br>
                                Brand Online
                            </li></a>
<a href="services.html#brandmarketing">
                            <li><img class="imgcenter" src="images/Brand-Marketing-Circle-Blue.png" width="100px" />
                                <br>
                                Brand Marketing
                            </li></a>
<a href="services.html#brandmanagement">
                            <li><img class="imgcenter" src="images/Brand-Management-Circle-Blue.png" width="100px" />
                                <br>
                                Brand Management
                            </li></a>

                </ul>
            </li>
            <li>    <a href="">Clients</a>

            </li>
            <li>    <a href="">About</a>

            </li>
            <li>    <a href="">Contact Us</a>

            </li>
        </ul>
    </div>
</div>
</div>

and this CSS:

    .header {
    position: fixed;
    display: block;
    float: left;
    width: 100%;
    height: auto;
    background-color: #666;
    z-index: 9999;
}

.nav {
    position: static;
    float: left;
    width: 500px;
    height: 50px;
    margin: 10px 5px;
}

.nav a {
    text-decoration: none;
    color: #FFFFFF;
}

.nav ul > li:first-child {
    padding-bottom: 25px;
}

.nav a:hover {
    text-decoration: none;
    color: #6db6e5;
}

.nav li {
    font-family: "eras_demi_itcregular", Arial, Helvetica;
    list-style: none;
    float: left;
    margin-right: 50px;
}

.nav li:hover a:hover {
    padding-bottom: 5px;
    border-bottom: 2px solid #6db6e5;
    color: #6db6e5;
}
.nav ul li:hover > ul {
    height:150px;

}
.nav ul {
    list-style: none;
    position: absolute;
    display: inline-block;
    margin-top: 23px;
}

.nav ul ul {
    width: 494px;
    background: #7d7c7c;
    height: 0px;
    overflow: hidden;
    padding-left:0;
    margin-left:0;
    font-size: 12px;
    text-align: center;
    -webkit-transition:all .5s ease-in-out;
  -moz-transition:all .5s ease-in-out;
  -o-transition:all .5s ease-in-out;
  transition:all .5s ease-in-out;    
}

.nav ul ul li {
    padding: 10px;
    margin-left: -1px;
    margin-right: 0;
    height: 129px;
}

.nav ul ul li:last-child {

}

.nav ul ul li:hover {
    background: #666;
}

.nav li li { 
  height:130px; 
  -webkit-transition:all .3s ease-in-out;
 }

Can anyone please tell me how I can make it so that the submenu can be wider than the main menu?

Was it helpful?

Solution

Try adding this to your CSS:

nav ul ul {
    width: 100vw;
    left: 0;
}

Fiddle: http://jsfiddle.net/9QE58/1/embedded/result/

That should keep it at 100% of the viewport width no matter what the pixel width is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top