问题
Is there an easy way to have a "glass pane" all over the HTML page, regardless of zoom/slide events/platform/browser{mobile/desktop}?
By "easy" I mean something like pure CSS support, not a plug-in.
Fallback: plug-in advice might be useful as well.
Thanks
回答1:
If you just mean a layer on top of everything, try this:
#top-layer {
position: fixed;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
top: 0;
left: 0;
}
You can set opacity: 0.5; if you want it semi-transparent.
A jsFiddle example
回答2:
I would use a class to do this.
div.glass-pane {
width: 100%;
height: 100%;
z-index: 10;
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
}
You can change the height, width, top, and left position to make the "glass pane" only fit over a certain area. Also you can add some color (rgba or hsla would be the best and create a glass effect). The z-index will help if you want to create a modal box on top of the pane. Then just use jQuery to add click events.
I recently published a Chrome Extension that uses this effect (here is the source).
回答3:
A glass pane? Try this CSS:
div#glassPane {
height: 98%;
width: 98%;
border: 1px solid rgba(0,0,0,0.5);
border-radius: 10px;
background: rgba(0,0,0,0.25);
box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
position: fixed;
top: 1%;
left: 1%;
}
See here for an example: http://jsfiddle.net/vLTWK/
See here for more:
http://dev.opera.com/articles/view/beautiful-ui-styling-with-css3-text-shadow-box-shadow-and-border-radius/#glassbox
来源:https://stackoverflow.com/questions/9079462/glass-pane-all-over-the-page