2012-05-11 41 views
5

如何使外部邊界半徑曲線在外?外部邊界半徑CSS屬性曲線

enter image description here

底側邊框半徑要彎道外側。如何用CSS3做到這一點?

+0

,無需額外的標記這將是不可能的,因爲圖形的部分是外箱子模型。 – Paul

回答

5

是的,你可以做到這一點,沒有任何額外的標記。像這樣寫:

CSS

.active{ 
    border:1px solid red; 
    border-bottom:0; 
    width:80px; 
    height:40px; 
    margin:30px; 
    position:relative; 
    -moz-border-radius:5px 5px 0 0; 
    -webkit-border-radius:5px 5px 0 0; 
    border-radius: 5px 5px 0 0; 
} 
.active:after, 
.active:before{ 
    content:''; 
    width:40px; 
    height:30px; 
    border:1px solid red; 
    position:absolute; 
    bottom:-3px; 
    border-top:0; 
} 
.active:after{ 
    border-left:0; 
    -moz-border-radius:0 0 5px 0; 
    -webkit-border-radius:0 0 5px 0; 
    border-radius: 0 0 5px 0; 
    left:-41px; 
} 
.active:before{ 
    border-right:0; 
    -moz-border-radius:0 0 0 5px; 
    -webkit-border-radius:0 0 0 5px; 
    border-radius: 0 0 0 5px; 
    right:-41px; 
} 

HTML

<div class="active">hi</div> 

入住這http://jsfiddle.net/p6sGJ/

+0

你忘了添加「真正的」border-radius屬性。我們不希望再有這種瘋狂:http://remysharp.com/2012/02/09/vendor-prefixes-about-to-go-south/ – peirix

+0

這很好,但我舉了一個例子,支持-webkit &mozilla瀏覽器:) – sandeep

+1

是的,但問題是有人可能會複製粘貼你的代碼,這可能是第一個問題的開始。所以我只是對答案做了一個快速編輯,順便提一下,這是一個很好的解決方案,所以我們可以儘量避免這種情況。 – peirix