2012-01-05 47 views
2
下面

是什么我谈论的图像:如何在它们之间创建带有拱门的选项卡?

enter image description here

我可以让这个纯CSS?

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

+0

你可以给四角采用CSS边界半径,但你很可能需要使用一些图像来获得上述效果。 http://www.css3.info/preview/rounded-border/ – Anagio 2012-01-05 22:07:54

+1

如果你想要一个适当的解决方案,请显示你已经尝试过,所以人们不会浪费他们的时间尝试相同的事情,或告诉你你已经知道什么。 – 2012-01-05 22:12:37

+0

我更新了操作 – user701510 2012-01-05 22:28:08

回答

1

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

+0

请注意,在链接之间,它们向外翻边。小心解释这是如何用'border-radius'完成的? – 2012-01-05 22:10:36

+0

@Madmartigan,你只需要在所有链接之间放置一个虚拟的div,并将其设置为带有border-radius的顶角;对于链接div风格的底部角落与边界半径 – rahool 2012-01-05 22:19:13

+0

你应该引导你的建议对用户701510,并编辑解决方案到你的文章,而不是评论。 – 2012-01-05 22:21:37

1

在这里,您可以使用负边界半径

http://lea.verou.me/2011/03/beveled-corners-negative-border-radius-with-css3-gradients/

它可能不是在所有浏览器兼容,你最安全的使用图像用于向外半径

更新我的答案用纯CSS无负半径 http://jsfiddle.net/peter/QTS6N/1/

+0

我不确定负边界半径如何帮助它进入内部? – user701510 2012-01-05 22:27:36

+0

有了两个div,第一层可以有橙色的顶部边框。另一个div覆盖持有ul和li元素。每个其他li元素可以在设置了填充或边距的选项卡之间具有负边界,并且您可以使用纯CSS获得效果,但图形将是安全的方式。 – Anagio 2012-01-05 22:39:07

+0

这里是一个jsfiddle,展示了一种使用纯CSS的方法http://jsfiddle.net/peter/QTS6N/1/ – Anagio 2012-01-05 22:55:21

1

你可以尝试使用'负边界半径',基本上是径向渐变(可能不是跨浏览器兼容可能值得使用图形)。看看this article。祝你好运!

+0

刚刚注意@Anagio殴打我,在那一个拳头! – huzzah 2012-01-05 22:17:57

+0

我不确定负面的边界半径会如何帮助,因为它会向内? – user701510 2012-01-05 22:22:48

+0

根据我的理解,它不是一个真正的负边界半径,它是一个径向渐变,使您看起来像使用负边界半径。老实说,如果是我,我会使用图形,如果这是必须具备的,因为径向渐变效果不是完全支持的功能(互联网爆发,咳嗽咳嗽),而且从我阅读的内容在文章中,采取了大量的css,使其在支持它的浏览器中看起来像你想要的样子。 – huzzah 2012-01-05 22:38:51

2

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

这些覆盖图应该使用伪类: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/

+0

第一个白色':after'元素位于'档案'选项卡中,而不是在外面。 – user701510 2012-01-05 23:04:13

+0

@ user701510你可以制作截图吗?我不确定你是什么意思。 (和什么浏览器?) – 2012-01-05 23:06:33

+0

Firefox 8,http://tinypic.com/view.php?pic=15oz51j&s=5 – user701510 2012-01-05 23:34:43

相关问题