0

I am trying to make my horizontal menu have round edges, however the inner "li" elements seem to overlap the div layer.

Here is an example for what I mean:

<div class="menu">
<ul>
    <li>Home</li>
    <li>Test</li>
    <li>Test 2</li>
</ul>

.menu {
     background-color:#CCC;
    border-radius:10px;
    border:1px solid black;
    z-index:9999999;
}

ul {
    list-style-type:none;
    margin:0;
    padding:0;
    z-index:-9999;
}

li {
    display:inline;
    background-color:red;
    z-index:-9999;
}

Here is the fiddle http://jsfiddle.net/3zeUg/ Have a look at the very left li element, it overlaps with it's square border into the round border.

I tried setting z-indexes without any success. I also tried giving the li elements a round border, but then each of the elements has a round border, which I don't want and since I am working on a wordpress theme, I should stick to the standards that are given.

I came across this website here: http://mypeoplesrock.com/ and in the menu you can see he has round borders but the inside element doesn't overlap. Looking at his css file, I can't seem to find what he did differently.

Thank you

Kevin M
  • 1,060
  • 11
  • 25

7 Answers7

1

Just add overflow: hidden; to .menu to prevent inner elements to bleed through the border.

Use the positioning method of your choice to refine the layout inside of the menu afterwards.

David Aurelio
  • 474
  • 2
  • 10
0

you can use text-indent;

ul {
...
text-indent: 15px;
...
}

or margin-left;

ul {
...
margin: 0 0 0 15px;
...
}
Umut D.
  • 1,557
  • 20
  • 22
0

Try to add padding-left: 5px; to your .menu CSS

PierreF
  • 2,250
  • 4
  • 22
  • 40
0

I suppose you are talking about DEMO

li:first-child{
   border-top-left-radius:10px; 
   border-bottom-left-radius:10px;
}
4dgaurav
  • 10,721
  • 4
  • 27
  • 55
0

Just play around with the padding inside of .menu.

HTML

<div class="menu">
    <ul>
        <li>Home</li>
        <li>Test</li>
        <li>Test 2</li>
    </ul>
</div>

CSS

.menu {
 background-color:#CCC;
border-radius:10px;
border:1px solid black;
z-index:9999999;
padding: 10px;
}

ul {
list-style-type:none;
margin:0;
padding:0;
z-index:-9999;
}

li {
display:inline;
background-color:red;
z-index:-9999;
}
ardzy
  • 49
  • 1
  • 5
0

You could try adding "overflow: hidden" to the "menu" class. This will hide the parts of the list going outside of the div.

.menu {
     background-color:#CCC;
    border-radius:10px;
    border:1px solid black;
    z-index:9999999;
    overflow: hidden;
}

You could also try adding rounded corners to the first list element in the list.

li:nth-of-type(1) {
    -webkit-border-top-left-radius: 10px;
    -webkit-border-bottom-left-radius: 10px;
    -moz-border-radius-topleft: 10px;
    -moz-border-radius-bottomleft: 10px;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}
Weston
  • 416
  • 1
  • 9
  • 17
0

You can use

li:first-child {
   -moz-border-top-left-radius:10px;
   -webkit-border-top-left-radius:10px;
   border-top-left-radius:10px;
   -moz-border-bottom-left-radius:10px;
   -webkit-border-bottom-left-radius:10px;
   border-bottom-left-radius:10px;
}
Luan Cuba
  • 73
  • 6