私はうまく機能するライトボックスコードを持っています! ボタンをクリックすると、黒い画面とコンテンツ ボックスのオーバーレイが表示されます。white_content
ユーザーがページをどれだけ下にスクロールしたかに基づいて、ライトボックスまたは以下の CSS を画面に表示する方法があるかどうかを知りたいです。
white_content
基本的には、表示可能な画面の真ん中に表示させたいと思っています。
http://s1309.beta.photobucket.com/user/mievan123/library/Light%20Box
最初の画像は、ページの中央に配置されたライト ボックスを示しています。これが私が望むものです。ページの一番下までスクロールします。
また、 http://www.green-panda.com/solutions.htmlで実際に動作しているのを見ることができます。
2 番目の画像は、ライト ボックスがページ上でほとんど見えないことを示しています。ご覧のとおり少しだけ上にスクロールしました。赤いアウトラインは、その位置にいるときにライト ボックスを移動させたい場所です。
画面の記録は、この質問をより明確にするのに役立ちますか?
私のコードはすべて以下に提供されています:
ライトボックス用の私のCSS
.black_overlay{
display: none;
position: fixed;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position: absolute;
top: 50%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
border: 16px solid green;
background-color: white;
z-index:1002;
overflow: auto;
}
ライトボックスを開くスクリプト
<p align="right">
<a href="javascript:void(0)"
class="button"
onclick="document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'"
>Contact Us</a>
</p>
実際のライトボックスのコーディング
<div id="light" class="white_content">
This is the lightbox content.
<a href="javascript:void(0)"
onclick = "document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none'"
>Close</a>
</div>
<div id="fade" class="black_overlay"></div>