heron
heron

Reputation: 3661

CSS Ul li navigation issue: Can't get correct result

Trying to get following result when I hover

enter image description here

for markup below

                <ul>
                    <li><a href="#">Current Month</a></li>
                    <li><a href="#">Current Week</a></li>
                    <li><a href="#">Previous Month</a></li>
                    <li><a href="#">Previous Week</a></li>
                    <li><a href="#">Next Month</a></li>
                    <li><a href="#">Next Week</a></li>
                    <li><a href="#">Team Calendar</a></li>
                    <li><a href="#">Private Calendar</a></li>
                    <li><a href="#">Settings</a></li>
                </ul>

Can't figure out solution using CSS3 border-radius. Any suggestions?

Update

Please don't post dotted lists. I need solution for arrowed list.

It's not same thing: when you use arrow, you need to set it as background-image of li.

There is another way, to set arrow as a bullet picture, but this time you have no way to control gap between arrow and link.

Upvotes: 2

Views: 175

Answers (4)

jah
jah

Reputation: 1305

body {
background-color: #F3F3F3;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: Arial, Tahoma;
    font-size: 13px;
    border-left: 1px solid #4AFFFF;
    padding-left: 10px;
}

li {
    margin: 0;
    padding: 0;
}

li:before {
    content: " ";
    display:inline-block;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-color: transparent transparent transparent #000000;
}

li a {
    margin-left: 5px;
    display: inline-block;
    border-radius: 3px;
    color: #000;
    padding: 3px 5px;
    text-decoration: none;
    width: 150px;
}

li a:hover {
    background-color: #DBDBDB;
    font-weight: bold;
}

This should be ezactly how you want it!

http://jsfiddle.net/2JJaW/

Upvotes: 2

Jason
Jason

Reputation: 3360

li:hover {
  background-color:#e4e4e4;
  -webkit-border-radius: 5px; 
  -moz-border-radius: 5px; 
  border-radius: 5px; 
}

jsfiddle

EDIT

If you want to use arrows instead, just use the :before pseudo element.

ul {
     list-style-type:none;
}    

li {

    padding:5px;
}

li:hover {

      width:100px;
      background-color:#e4e4e4;
      -webkit-border-radius: 5px; 
      -moz-border-radius: 5px; 
      border-radius: 5px; 

    }


li:before {
    content:"> ";

}

updated jsFiddle

Just replace the > with your image.

EDIT 2

To have the background only over the text, just add that style to the link instead of the li then.

http://jsfiddle.net/SEzxP/2/

EDIT 3

To use an image instead, just use url() after content

li:before {  content:url('http://www.nationalacademies.org/xpedio/groups/system/documents/webgraphics/na_right_arrow.gif') /* with class ModalCarrot ??*/
}

Updated jsFiddle

Upvotes: 3

Josh Crozier
Josh Crozier

Reputation: 240908

Something like this?

jsFiddle here

CSS

ul {
    list-style:none;
    background:#E6E6E6;
    border-left:3px solid rgb(0, 194, 255);
}
li a {
    text-decoration:none;
    color:black;
}
li a:hover {
    border-radius:5px;
    background: #cacaca;
}
li:before {
    content:"►";
    font-size:10px;
    margin-right:10px;
}

Upvotes: 2

Brian Ogden
Brian Ogden

Reputation: 19212

    <style>
        .my-list li a{
        text-decoration:none;
        color:#000;
    }


.my-list li a:hover
    {
        -moz-border-radius: 4px;
        -webkit-border-radius: 4px;
        border-radius: 4px;
        text-decoration: none;
        background-color: #e4e4e4;
    }

    .my-list li{
        list-style-image:url(http://www.nationalacademies.org/xpedio/groups/system/documents/webgraphics/na_right_arrow.gif)
    }
    </style>        




    <ul class="my-list">
         <!--Example of gap using whitespace-->
         <li>&nbsp;&nbsp;<a href="#">Current Month</a></li>
         <!--Example of a gap using padding for finer control of desired gap-->
         <li><a style="padding-left:20px;" href="#">Current Week</a></li>
         <li><a href="#">Previous Month</a></li>
         <li><a href="#">Previous Week</a></li>
         <li><a href="#">And so on...</a></li>
      </ul>

See jsFiddle also: http://jsfiddle.net/KRaJN/3/

Upvotes: 3

Related Questions