admin管理员组

文章数量:1277887

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

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

Share Improve this question asked Jan 31, 2012 at 12:24 Alexander AbramovichAlexander Abramovich 11.5k26 gold badges74 silver badges113 bronze badges 1
  • Do you mean a layer on top of everything? – MMM Commented Jan 31, 2012 at 12:25
Add a ment  | 

3 Answers 3

Reset to default 6

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

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).

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/vLTWK/

See here for more:
http://dev.opera./articles/view/beautiful-ui-styling-with-css3-text-shadow-box-shadow-and-border-radius/#glassbox

本文标签: javascriptGlass pane all over the pageStack Overflow