私は以前の問題を更新しましたが、これは私が遭遇した新しい問題です。モーダルポップアップが背景を上にスクロールします
オンhttp://www.christianluneborg.comウェブサイト。 「ウェブサイト」リンクをクリックし、「純粋なネットワーク」のイメージをクリックしてください。モーダルがポップアップし、ページの背景がホームページまでスクロールして表示されます。それをどうやって止めるの?それはページの「ウェブサイト」セクションにとどまる必要があります。
HTML -
<div class="image-wrap">
<a href="#" onclick="lightbox_open();"><img src="img/img2.jpg" alt="Pure Network"></a>
</div>
モーダル -
<div id="Modal-Pure">
<a href="#" onclick="lightbox_close();"><img src="img/website151.jpg" alt="" /></a>
</div>
<div id="fade" onClick="lightbox_close();"></div>
CSS -
#fade {
display: none;
position: fixed;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.4;
opacity:.50;
filter: alpha(opacity=50);
}
#Modal-Pure {
display: none;
position: fixed;
top: 25%;
left: 35%;
width: 836px;
height: 636px;
margin-left: -150px;
margin-top: -100px;
background: #000;
z-index:1002;
overflow:hidden;
}
Javascriptを -
<script>
window.document.onkeydown = function (e)
{
if (!e){
e = event;
}
if (e.keyCode == 27){
lightbox_close();
}
}
function lightbox_open(){
document.getElementById('Modal-Pure').style.display='block';
document.getElementById('fade').style.display='block';
}
function lightbox_close(){
document.getElementById('Modal-Pure').style.display='none';
document.getElementById('fade').style.display='none';
}
</script>
ありがとうございます!しかし、これらの写真をクリックすると、同じ画像がポップアップします。私はモーダルポップアップの別のイメージでそれを必要とします –
あなたはフルサイズの画像をポップアップしたいのですか?最後の編集では、データ属性を使用して余分な情報を保存できると述べました。たとえば、各画像に 'data-src'属性を追加して、フルサイズの画像パスを保存することができます。 JSコードで 'this.src'を' this.dataset.src'に置き換えてください。 – Mikey
それは完璧にうまくいった!ありがとうございました! –