2015-08-31 78 views
-2

我想使用css或任何其他可能的選項創建此形狀。可能嗎?這種形狀有沒有內部負邊界?使用css創建帶有此邊框的形狀

enter image description here

感謝

+0

也許這有助於:https://css-tricks.com/examples/ShapesOfCSS/ – Kristine

+1

您可以製作一個正方形的div和一個白色的圓形,並放置在方形div上。它會使這個形狀。 – Vinayak

回答

2

這樣的事情?

.shape{ 
 
    display:inline-block; 
 
    position:relative; 
 
    background-color:black; 
 
    width:60px; 
 
    height:60px; 
 
    padding-top:20px; 
 
    overflow:hidden; 
 
} 
 
.shape:before{ 
 
    position:absolute; 
 
    top:-20px; 
 
    left:0; 
 
    width:100%; 
 
    height:40px; 
 
    border-radius:50%; 
 
    content:""; 
 
    background-color:white; 
 
}
<div class="shape"> 
 
</div>

0

請試試這個

.flag { 
    width: 110px; 
    height: 56px; 
    padding-top: 25px; 
    position: relative; 
    background: red; 
    color: white; 
    font-size: 11px; 
    letter-spacing: 0.2em; 
    text-align: center; 
    text-transform: uppercase; 
} 
.flag:after { 
    content: ""; 
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 0; 
    height: 0; 
    border-top: 13px solid #eee; 
    border-left: 55px solid transparent; 
    border-right: 55px solid transparent; 
} 

Demo

Demo1

0

你可以做的選擇:前後加邊界半徑爲僞元素。

哈克方式可能不會對你有任何好的,但在這裏我們去:

<style> 


.test {background: #000; 
      width:100px; 
      height:100px; 
      color:#fff; 
      padding:40px; 

     } 
    .test:before { 
     position: absolute; 
     left:0; 
     top:-10px; 
     width:200px; 
     height:40px; 
     border-radius: 50%; 
     content:''; 
     background-color: #fff; 
    } 
</style> 




<div class="test"> 

     this is a rtest content 
    </div> 

,或者你可以使用SVG的背景:)

0

小提琴簡單的理解:

[這裏] [1]

[1]: http://jsfiddle.net/vinayak5192/71t70Lbp/