Reputation: 152677
Is it possible to make a "hole" in an element (div, span) like this using CSS. I know I can do it with a transparent image but I'm just curious to know if it's possible in CSS.
body {padding:70px; background:url(http://ipadinsight.com/wp-content/uploads/2011/11/AirPlayMirroring_thumb.jpg)}
div {background:red;border-radius:10px;width:400px;height:100px}
Try at jsfiddle here http://jsfiddle.net/xqEV2/
Upvotes: 5
Views: 9955
Reputation: 92793
Yes; you can do it with pure css. Like this:
body {padding:70px; background:url(http://ipadinsight.com/wp-content/uploads/2011/11/AirPlayMirroring_thumb.jpg);}
.parent {background:red;border-radius:10px;width:400px;height:100px;position:relative;}
.circle{
float:right;
position:absolute;
right:-50px;
top:0;
bottom:0;
width:50px;
overflow:hidden;
}
.circle:after{
content:"";
width:40px;
height:40px;
-moz-border-radius:100px;
display:block;
border:red 50px solid ;
margin-left:-45px;
margin-top:-20px;
}
Check this live example
Upvotes: 6
Reputation: 75609
You can simulate a hole by setting the same background image for the hole as the underlying element. That does not make it really transparent.
Upvotes: 0
Reputation: 19
No, A DIV is a "solid object".
You can on the other hand use a transparent picture(png or gif) to make something look like a hole. you wont be able to interact with the layer underneth as long as you havent changed the z-index..
You maybe could use borders to make it look like a box and keep the background-color:transparent
Upvotes: -1