How do I add curved corners to menu in css


Tags: html,css

Problem :

I want to curve the corners in css in .second-level-menu.

I tried to add in .second-level-menu and in .second-level-menu > li:

border-radius: 0px 0px 8px 8px; 
-moz-border-radius: 0px 0px 8px 8px; 
-webkit-border-radius: 0px 0px 8px 8px; 

/* Menu Styles */

.third-level-menu {
  position: absolute;
  top: 0;
  right: -150px;
  width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
}
.third-level-menu > li {
  height: 30px;
  background: #999999;
}
.third-level-menu > li:hover {
  background: #CCCCCC;
}
.second-level-menu {
  position: absolute;
  top: 30px;
  left: 0;
  width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
}
.second-level-menu > li {
  position: relative;
  height: 30px;
  background: #999999;
}
.second-level-menu > li:hover {
  background: #CCCCCC;
}
.top-level-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.top-level-menu > li {
  position: relative;
  float: left;
  height: 30px;
  width: 150px;
  background: #999999;
}
.top-level-menu > li:hover {
  background: #CCCCCC;
}
.top-level-menu li:hover > ul {
  /* On hover, display the next level's menu */
  display: inline;
}
/* Menu Link Styles */

.top-level-menu a
/* Apply to all links inside the multi-level menu */

{
  font: bold 14px Arial, Helvetica, sans-serif;
  color: #FFFFFF;
  text-decoration: none;
  padding: 0 0 0 10px;
  /* Make the link cover the entire list item-container */
  display: block;
  line-height: 30px;
}
.top-level-menu a:hover {
  color: #000000;
}
<ul class="top-level-menu">
  <li><a href="#">About</a>
  </li>
  <li><a href="#">Services</a>
  </li>
  <li>
    <a href="#">Offices</a>
    <ul class="second-level-menu">
      <li><a href="#">Chicago</a>
      </li>
      <li><a href="#">Los Angeles</a>
      </li>
      <li>
        <a href="#">New York</a>
        <ul class="third-level-menu">
          <li><a href="#">Information</a>
          </li>
          <li><a href="#">Book a Meeting</a>
          </li>
          <li><a href="#">Testimonials</a>
          </li>
          <li><a href="#">Jobs</a>
          </li>
        </ul>
      </li>
      <li><a href="#">Seattle</a>
      </li>
    </ul>
  </li>
  <li><a href="#">Contact</a>
  </li>
</ul>



Solution :

It works with border-radius, you just can't see it because the overlapping li elements. Setting overflow:hidden to .second-level-menu will cause the radius to show.

/* Menu Styles */

.third-level-menu {
  position: absolute;
  top: 0;
  right: -150px;
  width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
}
.third-level-menu > li {
  height: 30px;
  background: #999999;
}
.third-level-menu > li:hover {
  background: #CCCCCC;
}
.second-level-menu {
  position: absolute;
  top: 30px;
  left: 0;
  width: 150px;
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
  border-radius:0px 0px 8px 8px;
  overflow:hidden;
}
.second-level-menu > li {
  position: relative;
  height: 30px;
  background: #999999;
}
.second-level-menu > li:hover {
  background: #CCCCCC;
}
.top-level-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.top-level-menu > li {
  position: relative;
  float: left;
  height: 30px;
  width: 150px;
  background: #999999;
}
.top-level-menu > li:hover {
  background: #CCCCCC;
}
.top-level-menu li:hover > ul {
  /* On hover, display the next level's menu */
  display: inline;
}
/* Menu Link Styles */

.top-level-menu a
/* Apply to all links inside the multi-level menu */

{
  font: bold 14px Arial, Helvetica, sans-serif;
  color: #FFFFFF;
  text-decoration: none;
  padding: 0 0 0 10px;
  /* Make the link cover the entire list item-container */
  display: block;
  line-height: 30px;
}
.top-level-menu a:hover {
  color: #000000;
}
<ul class="top-level-menu">
  <li><a href="#">About</a>
  </li>
  <li><a href="#">Services</a>
  </li>
  <li>
    <a href="#">Offices</a>
    <ul class="second-level-menu">
      <li><a href="#">Chicago</a>
      </li>
      <li><a href="#">Los Angeles</a>
      </li>
      <li>
        <a href="#">New York</a>
        <ul class="third-level-menu">
          <li><a href="#">Information</a>
          </li>
          <li><a href="#">Book a Meeting</a>
          </li>
          <li><a href="#">Testimonials</a>
          </li>
          <li><a href="#">Jobs</a>
          </li>
        </ul>
      </li>
      <li><a href="#">Seattle</a>
      </li>
    </ul>
  </li>
  <li><a href="#">Contact</a>
  </li>
</ul>


    CSS Howto..

    CSS: How to remove the space around? [duplicate]

    How to modify only via CSS a color already defined in HTML?

    CSS - How to remove white
    margins

    How to use css to style xhtml markup made only of divs like a table [closed]

    How would I have a larger center bottom navbar button in jQuery Mobile default navbar?

    How To Prevent CSS Background Image From Moving When Shown?

    How To Slide One Image Out From Behind Another On Hover?

    How to do animation of using CSS and webkit

    How to dynamically manipulate elements in HTML

    How to style diff implementation for PHP with CSS

    How can I hide page elements till an AJAX call completes?

    How to have an asp.net ajax control automatically reference css files

    How to display parent form when input text is on focus?

    How do I make footer take 100% of the width of the webpage?

    How this switch button work by CSS?

    How to prevent Ajax overflow/server crash? (Arduino/ESP8266 Environment)

    How to convert an element css to JSON? [duplicate]

    How can I find which file or code affected to my code in html, css

    Show a caption with a semi-transparent color overlay when hovering over an image

    How to not change color of link on hover

    How to style this with css? [closed]

    In a 3 column grid of a varying number of elements, how to select only the elements that appear on the last line using CSS

    How to place div in top right hand corner of page

    How does reveal.js resize elements?

    How do I put these on the same line?

    How to create a css hoverover box with two section

    How to embed fonts in CSS?

    How can I make this kind of a border?

    CSS Media Queries: How to make the right column display above the left on small screens?

    How to set alternating color to nested and sibling divs with certain class.