2012-01-05 15 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

相關問題