Question

I have this css menu that is currently displaying a CSS / HTML menu vertical

#nav {
    margin:-20px 0 0 2px;
    top:0;
    left:0;
    width: 100%; 
    list-style:none;
}
#nav li a {
    display: block; 
    padding: 4px 10px;
    margin-bottom:0;
    background: #666666; 
    border-top: 1px solid #EEEEEE; 
    border-bottom: 1px solid #EEEEEE; 
    text-decoration: none; 
    color: #EEEEEE;
    width:155px;
}
#nav li a:hover, #nav li a.active {
    background: #F36F25; 
    color: #FFFFFF;
    cursor:pointer;
}
#nav li ul {
    display: none;
    list-style:none;
}
#nav li ul li {
    margin-top:0;
    margin-right:0;
    margin-bottom:0;
    margin-left:-40px;
}
#nav li ul li a {
    background: #EEEEEE;
    color:#666666;
    border:1px solid #EEEEEE;
}
#nav li ul li a:hover {
    background: #EEEEEE;
    color:#f36f25;
    border:1px solid #f36f25;
}

how can i make it display horizontal rather than vertical?

I have created a fiddle here with the full HTML and CSS Code

http://jsfiddle.net/SV74d/

Était-ce utile?

La solution

Add this to your CSS:

#nav li {
    display: inline;
}

And change:

#nav li a {
    display: inline; 

to:

#nav li a {
    display: inline-block; 

It will display your li elements inline and only stack them vertically when the viewport isn't long enough.

Autres conseils

You could float the li's left I suppose.

#nav li{
  float: left;
}

Basically setting the li element to display inline

li {
    display:inline;
}

http://jsfiddle.net/SV74d/2/

Try this

#nav li {

    display : inline-table;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top