Search code examples
htmlcsssizewidthnav

Auto width for nav li tags


I am trying to make my nav I am trying to make my navI am trying to make my navI am trying to make my navI am trying to make my navI am trying to make my navI am trying to make my navI am trying to make my navI am trying to make my nav

<div class="headercss">class="header">

    <div class="headerlogo">class="header">

    </div>


</div>

/* BODY */

body {
    margin: 0px;
    background-color: #000000;
}


/* 1. HEADER */

.headercssheader {
    width: auto;
    height: 500px;
    position: relative;
}

.headerlogoheader {
    width: 980px;
    height: 250px;
    position: relative;
    left: 50%;
    margin-left: -490px;
}

.nav {
    width: 980px;
    height: 70px;
    position: relative;
    left: 50%;
    margin-left: -490px;
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

li {
    float: left;
}

a:link, a:visited {
    display: block;
}

a:hover, a:active {
}

Solution

  • Give width in % according to number of your items in list.

    ul{ list-style-type: none;
            margin: 0;
            padding: 0;
            float:left;
            width:100%;
            overflow: hidden;
        }
    
    li {
        float: left;
        width:25%;
    }