Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
启用模式弹出式Javascript中的滚动_Javascript - Fatal编程技术网

启用模式弹出式Javascript中的滚动

启用模式弹出式Javascript中的滚动,javascript,Javascript,我使用模式视图在弹出视图中显示图像,但并没有滚动功能,我想添加它,有人能帮我编写代码吗 脚本: <script> // Get the modal var modal3 = document.getElementById('myModal3'); // Get the image and insert it inside the modal - use its "alt" text as a caption var img3 = $('.myImg3'); va

我使用模式视图在弹出视图中显示图像,但并没有滚动功能,我想添加它,有人能帮我编写代码吗

脚本:

<script>
// Get the modal
var modal3 = document.getElementById('myModal3');

// Get the image and insert it inside the modal - use its "alt" text as a caption
var img3 = $('.myImg3');
var modalImg3 = $("#img03");
var captionText3 = document.getElementById("caption3");
$('.myImg3').click(function(){
    modal3.style.display = "block";
    var newSrc3 = this.src;
    modalImg3.attr('src', newSrc3);
    captionText3.innerHTML = this.alt;
});

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("clos")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal3.style.display = "none";
}
</script>

//获取模态
var modal3=document.getElementById('myModal3');
//获取图像并将其插入模式-使用其“alt”文本作为标题
变量img3=$('.myImg3');
var modalImg3=$(“#img03”);
var captionText3=document.getElementById(“caption3”);
$('.myImg3')。单击(函数(){
modal3.style.display=“块”;
var newSrc3=this.src;
modalImg3.attr('src',newSrc3);
captionText3.innerHTML=this.alt;
});
//获取关闭模态的元素
var span=document.getElementsByClassName(“clos”)[0];
//当用户单击(x)时,关闭模式对话框
span.onclick=函数(){
modal3.style.display=“无”;
}
HTML:

”>
&时代;

提前感谢。

尝试添加
overflow-y:auto到模态的主体:

<div id="myModal3" class="modal" style="overflow-y: auto;">

一般来说,这只是一个两部分的过程,即主包装(固定大小)和内容。在溢出滚动条上。
<div id="myModal3" class="modal" style="overflow-y: auto;">