How is it possible to create a hole in an overlay where you can see through to the actual website?
For example in this fiddle: http://jsfiddle.net/qaXRp/
I want the <div id="center">
to be transparent so that you can see the <div id="underground">
. Is it possible to do this only with CSS or do I have to use some JavaScript?
No. This is not possible, not in most browsers.
CSS Masking
You can use
masking
, if you are interested only in new browsers:Specs: http://www.w3.org/TR/css-masking/
Compatibility: http://caniuse.com/css-masks
Border / Outline
You can also use
border
oroutline
css properties if you want to create simular effect and set color of them totransparent
so it looks simular.Position Absolute
You can also use position:
Transparency and elements
http://css-tricks.com/non-transparent-elements-inside-transparent-elements/
http://css-tricks.com/examples/NonTransparentOverTransparent/
-- this is not what are you asking for, but it can helps you :)
This is possible, to a degree.
Option 1: Covering element with semi-transparent border
Option 2: 3x3 grid with the central element fully transparent
You can now achieve this with relatively good support in new webkit browsers using css clipping (see here for compatability).
For example, the following code would cut a hole with a radius of 100px (so 200px wide) in the center of your element (with a slightly feathered edge).
Here's a codepen to demonstrate.
Yes, this effect is possible.
I would use the css box-shadow with a very large spread radius.
This is not possible. But anyways you can do the border trick: The
#overlay
itself is transparent but The borders are not. See the fiddle: http://jsfiddle.net/qaXRp/2/