js+css realisiert die maskierte Popup-Ebene in der Mitte (Scrollen mit der Bildlaufleiste des Browserfensters)
Kopieren Sie den Codecode wie folgt:
<!doctype html>
<Kopf>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
*{}{margin:0;padding:0;}
html{}{_background:url(about:blank);} /**//* Flashen im IE6 verhindern, leere Dateien durch about:blank ersetzen, Anfragen reduzieren*/
body{}{background:#fff; Schriftart: 12px/1,5 Tahoma, Genf, //5b8b//4f53, serifenlose Höhe:100%;}
.wrap{}{height:980px; padding-top:20px;text-align:center;}
p{}{font-size:14px;text-align:center;line-height:24px;}
/**//** Maskenebene**/
#masklayer{}{
Hintergrund:#000;
Anzeige:keine;
filter:alpha(opazität = 50);
Deckkraft:0,5;
oben:0;
links:0;
Höhe: 100 %;
Breite: 100 %;
Z-Index:999;
Position:fest;
_position:absolut;
_left: expression(documentElement.scrollLeft + documentElement.clientWidth - this.offsetWidth);
_top: expression(documentElement.scrollTop + documentElement.clientHeight - this.offsetHeight);
}
/**//** Pop-up-Ebene**/
#popup{}{
Anzeige:keine;
Breite:300px;
Z-Index:1000;
links:50 %;
oben:50%;
Position:fest!wichtig;
margin-left:-150px !important;
_position:absolut;
_top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat')?
documentElement.scrollTop + (document.documentElement.clientHeight - this.offsetHeight)/2: /**//*IE6*/
document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2); /**//*IE5 IE5.5*/
}
.content{}{background:#f3f3f3;border:1px solid #999;}
.content h3{}{background:#a0a0a0;color:#fff;font-size:14px;height:32px;line-height:32px;padding-left:5px;}
#clickbtn{}{margin-top:20px;}
</style>
</head>
<Körper>
<div>
<p>
Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext
<br />
Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext
<br />
Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext
<br />
Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext
<br />
Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext. Ich bin der Haupttext
</p>
<input type="button" id="clickbtn" value="clike me" />
</div>
<div id="masklayer"></div>
<div id="popup">
<div>
<h3> Ist die Popup-Ebene zentriert? </h3>
<p>Mitte, Mitte, Mitte, Mitte, Mitte, Mitte</p>
<p>Mitte, Mitte, Mitte, Mitte, Mitte</p>
<p>Mitte, Mitte, Mitte, Mitte</p>
<p>Mitte, Mitte, Mitte</p>
</div>
</div>
<script type="text/javascript">
(function(masklayer){
var clickbtn = document.getElementById('clickbtn');
clickbtn.onclick = function(){
var popup = document.getElementById('popup');
masklayer.style.display='block';
popup.style.display ='block';
var h = popup.clientHeight;
with(popup.style){
marginTop = -h/2+'px';
}
}
})(document.getElementById('masklayer'))
</script>
</body>
</html>