I'm looking for a way to mask out part of a div so that what is behind is visible.
Looking at my example, I would like to replace the black circle with some sort of mask, so that as it slides down the text being revealed (or the background image) can be seen behind it.
jsfiddle
jQuery(document).ready(function() {
$('.img').click(function() {
$('.mid').slideToggle('slow');
});
});
YES, if you use a PNG image for the masking. It is possible to clip the background div using it's children. What you would need to do it use a PNG with transparent area in the middle or where ever you want. Save this answer.
First, we create a <div> element (class="background") with a background image, and a border. Then we create another <div> (class="transbox") inside the first <div>. The <div class="transbox"> have a background color, and a border - the div is transparent.
If you want to use only CSS, there is a really creative solution to your problem. You seperate the horizontal part where the "black hole" is from the others into three parts: left of the circular hole, the hole, and the right part. In the hole part you actually put a div with no background and a border with suitable border radius. As you already fixed all the width and height measurements, this further seperation should be no trouble.
Best example for how to is the whale : http://www.subcide.com/experiments/fail-whale/
This will be applicable for chomre 4.0+, IE 9+, Firefox 3+, Safari 3.1 and 5 as well as Opera 10.5 Make sure to also include the corresponding prefixes (-moz- and -webkit-)
Here's what I came up with this afternoon using:
background: radial-gradient(ellipse 200px 200px at 50% -25px, transparent 50px, green 0);
Looks like it works on all current browser versions too (I've only tested chrome and safari).
jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With