CaptainXD
CaptainXD

Reputation: 83

Separator between vertical menu items

I'm making a vertical menu for my website. It's supposed to have a mobile look and feel. The menu is almost complete, I just don't know how to add a subtle divot/separator between each menu item. Can someone show me how this is done?

I'm styling my menu off of JPanelMenu, so take a look if you like.

Here is the CSS for the menu:

#menu {
    position: absolute;
    top: 0;
    left: 100%;
    font-family: Ubuntu;
    font-size: 16px;
    color: #ffffff;
    height: 100%;
    width: 15%;
    background: #1b1b1b;
    display: none;
    box-shadow: -0px 0px 6px #888888;
    z-index: 2;
}

#menu a {
    color: white;
    text-decoration: none;
}

#menu li {
    list-style: none;
    padding-left: 5px;
    line-height: 50px;
}

#menulinks li:hover{
    background: #6b6b6b;
}

You can look at my site if you need a visual demonstration. http://ion.comli.com

Upvotes: 0

Views: 11461

Answers (2)

sheriffderek
sheriffderek

Reputation: 9043

Fiddle is here:

HTML

<ul class="menu">
    <li><a href="#">Overview</a></li>
    <li><a href="#">Usase</a></li>
    <li><a href="#">Inner-Workings</a></li>
    <li><a href="#">Animation</a></li>
    <li><a href="#">Options</a></li>
</ul>

CSS

.menu {
    padding: 0;
    list-style: none;
    max-width: 10em;
    overflow: hidden;
    background-color: gray;
}

.menu li {
    display: block;
    width: 100%;
    float: left;
    border-bottom: 1px solid rgba(0,0,0,.6);
    border-top: 1px solid rgba(255,255,255,.2);
}

.menu li a {
    display: block;
    width: 100%;
    float: left;

    font-family: arial;
    font-size: 1em;
    color: white;
    font-weight: bold;
    padding: .6em 1em;
    text-decoration: none;
    background-color: gray;
}

.menu li:first-of-type {
    border-top: none;
}

.menu li:last-of-type {
    border-bottom: none;
}

.menu li a {
    /* such ugly code */ 
    background: #7f7f7f;
    background: -moz-linear-gradient(top,  #7f7f7f 0%, #474747 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7f7f7f), color-stop(100%,#474747));
    background: -webkit-linear-gradient(top,  #7f7f7f 0%,#474747 100%);
    background: -o-linear-gradient(top,  #7f7f7f 0%,#474747 100%);
    background: -ms-linear-gradient(top,  #7f7f7f 0%,#474747 100%);
    background: linear-gradient(to bottom,  #7f7f7f 0%,#474747 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7f7f7f', endColorstr='#474747',GradientType=0 );
}

Upvotes: 1

AgmLauncher
AgmLauncher

Reputation: 7270

Just add border-bottom: 1px solid #ccc; to either #menu a or #menu li

And if you want to avoid a separator appearing at the bottom of the last menu item, just add this:

#menu a:last-of-type { /* or add it to #menu li */
    border-bottom: none;
}

Upvotes: 1

Related Questions