Tuesday, January 14, 2014

Horizontal and Vertical Menu

One HTML code, which will serve desktop, tablet and mobile views.



HTML:
 <nav>
           <div class="col-xs-12 col-sm-12 col-md-12" id="navigation">
                <ul>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">FAQ</a></li>
                </ul>
            </div><!-- navigation  -->
    </nav>
CSS:
header, nav {
    width: 976px;
    margin-left: auto;
    margin-right: auto;
}

nav {
    height: 130px;
}

#navigation ul
{
    margin: 0;
    padding-top: 15px;
    display: block;
    padding-bottom: 15px;
    height: 40px;
}

#navigation ul li
{
    list-style-type: none;
    display: inline;
}

#navigation li:before {
content: " | ";
padding-left: 30px;
padding-right: 30px;
color: white;
}

#navigation li:first-child:before {
content: none;
}

#navigation ul  {
    background-color: #6FB4D3;
}

#navigation li a {
    color: white;
 }

#navigation li a:hover {
    color: #000066;
    text-decoration: none;
}

Media -query:

@media screen and (max-width : 480px)
{
 #navigation ul li
    {
        display: block;
        list-style-type: none;
        height: 40px;
        width: 300px;
        padding-top: 15px;
        padding-bottom: 15px;
        margin: 0;
        text-align: center;
        border: solid 2px #FFFFFF; 
    }

    #navigation li:before { content: none;}
    #navigation li:first-child:before { content: none; }
 
#navigation ul  {
    background-color: #FFFFFF;
  }

  #navigation ul li  {
    background-color: #6FB4D3;
    }
  
  #navigation ul li
    {
         background-color: #6FB4D3; 
    }  

  #navigation li a {
    color: white;
    }

    #navigation li a:hover {
        color: #000066;
        text-decoration: none;
    }
}

No comments:

Post a Comment