首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何创建带有拱门的标签?

如何创建带有拱门的标签?
EN

Stack Overflow用户
提问于 2012-01-06 06:04:53
回答 4查看 265关注 0票数 2

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

我能用纯CSS做这件事吗?

更新:我已经创建了在右上角和左上角有圆角(使用边界半径)的div,并将它们放在选项卡之间。仍然在寻找一种更优雅的解决方案。

EN

回答 4

Stack Overflow用户

发布于 2012-01-06 06:47:03

最好的方法是在菜单项上覆盖一个元素,该元素本身就有一个边界半径。此元素必须具有与菜单容器相同的背景颜色。

这些覆盖应该使用伪类:before:after来完成。它们也有一个很棒的browser support

HTML:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
.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/

票数 2
EN

Stack Overflow用户

发布于 2012-01-06 06:08:12

是,使用border-radius属性。但是,border-radius是一个CSS3属性。

票数 1
EN

Stack Overflow用户

发布于 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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8750505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档