最簡單的方法是使用透明 DIV與溢出隱藏(灰色之一)
比裏面簡單地說用的box-shadow一個圓圈,真正的大蔓延。
html, body{height:100%;}
body{
background: url(http://web-vassets.ea.com/Assets/Richmedia/Image/Screenshots/FIFA-Street-London1web.jpg?cb=1330546446) 50%/cover;
}
.hasCircle{
width:150px;
height:300px;
position:relative;
overflow:hidden;
float:left;
}
.hasCircle:after{
content:" ";
position:absolute;
left:0; right:0;
margin:100px auto;
width:100px;
height:100px;
border-radius:50%;
box-shadow: 0 0 0 1000px #444;
}
<div class="hasCircle"></div>
<div class="hasCircle"></div>
<div class="hasCircle"></div>
正如你可以在上面看到我用這可能會導致一些文本中.hasCircle
可見(由於重疊僞元素)的:after
僞元素,但它只是得到一個想法,你可以使用像這樣的一個真實的元素:
<div class="boxTransparentOverflow">
<div class="theTransparentCircleWithGraySpread"></div>
Some text
</div>
最簡單的方法是隻是一個PNG。 – cport1 2014-10-30 13:50:41
http://stackoverflow.com/questions/22332755/build-a-rectangle-frame-with-a-transparent-circle-using-css-only – eclipsis 2014-10-30 13:52:18