下面是我正在讨论的内容的图像:

我能用纯CSS做这件事吗?
更新:我已经创建了在右上角和左上角有圆角(使用边界半径)的div,并将它们放在选项卡之间。仍然在寻找一种更优雅的解决方案。
发布于 2012-01-06 06:47:03
最好的方法是在菜单项上覆盖一个元素,该元素本身就有一个边界半径。此元素必须具有与菜单容器相同的背景颜色。
这些覆盖应该使用伪类:before和:after来完成。它们也有一个很棒的browser support。
HTML:
<ul class="tabs">
<li><a href="#">Archive</a></li>
<li><a href="#">Forum</a></li>
<li><a href="#">Store</a></li>
<li><a href="#">Patv</a></li>
</ul>
<br style="clear:both;" /> <!-- I didn't have an other element to clear the floats with -->CSS:
.tabs { /* generates the grey line on the very top */
width: 100%;
height: 5px;
background: grey;
}
.tabs li {
list-style-type: none;
float: left;
}
.tabs li:first-child {
margin-left: 30px; /* This is just to move the menu to the left, for demo purposes */
}
.tabs a {
text-underline: none;
color: black;
line-height: 30px;
padding: 10px 20px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
background: grey;
}
.tabs a:after, .tabs li:first-child a:before {
content: '';
width: 4px;
height: 25px;
background: white; /* This has to be the background color of the container. Change it to red to see the pseudo elements */
position: absolute;
margin-top: 5px;
margin-left: -3px;
border-radius: 10px;
}
.tabs a:after {
margin-left: 18px;
}这是一个演示:http://jsfiddle.net/rGubz/
发布于 2012-01-06 06:08:12
是,使用border-radius属性。但是,border-radius是一个CSS3属性。
发布于 2012-01-06 06:11:51
在这里你可以使用负的边框半径
http://lea.verou.me/2011/03/beveled-corners-negative-border-radius-with-css3-gradients/
它可能并不是在所有浏览器中都兼容,您最安全地使用图像作为向外半径
更新我的答案以使用没有负半径http://jsfiddle.net/peter/QTS6N/1/的纯CSS
https://stackoverflow.com/questions/8750505
复制相似问题