我想在.second-level-menu中对css中的角进行曲线化。
我尝试添加.second-level-menu
和.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>
答案 0 :(得分:1)
它适用于border-radius,你只是因为重叠的li元素而无法看到它。将overflow:hidden
设置为.second-level-menu
将导致显示半径。
/* 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>
答案 1 :(得分:1)
如果你添加overflow: hidden
,它会部分解决问题,但是你的第三级菜单是不可见的。我只想补充一下:
.second-level-menu > li:last-child {
border-radius: 0px 0px 8px 8px;
}
演示:https://jsfiddle.net/cw8w6rwr/
(如果需要,第三级菜单相同)