html - Mask effect below pop-up box using pure CSS -
i convert div on webpages pop-up box adding class, turnintooverlay
, div. (see jsfiddle)
.turnintooverlay { position: fixed; background-color: white; top: 60px; max-width: 680px; z-index: 80; border: 6px solid #bbb; box-shadow: 0 1px 10px rgba(0, 0, 0, 0.5); max-height: 800px; overflow: auto; padding:10px; }
now when pop displayed want create mask puts faded layer(or mask) rest other page elements appear below popup box. create mask, resorted pure css approach using psuedo selectors, mask shown/hidden when popup box( turnintooverlay
element) visible. added following css:
.turnintooverlay:after { content: ""; background-color: whitesmoke; position: fixed; width: 100%; height: 100%; z-index: -1; opacity: 0.5; top: 0; left: 0; }
everything works fine except mask appears on pop when keep z-index lower of popup. surprise, works when z-index=-1
. can please suggest how rectify ?
see jsfiddle here
my solution use both :before
, :after
solve problem:
.turnintooverlay { position: fixed; background-color: white; top: 60px; max-width: 680px; border: 6px solid #bbb; box-shadow: 0 1px 10px rgba(0, 0, 0, 0.5); max-height: 800px; overflow: auto; padding:10px; z-index: 80; } .turnintooverlay:before { content: ""; background-color: skyblue; position: fixed; width: 100%; height: 100%; z-index: -1; opacity: 0.4; top: 0; left: 0; } .turnintooverlay:after{ position: absolute; width: 100%; height: 100%; top: 0; left: 0; background-color: white; z-index: -1; content: ""; }
Comments
Post a Comment