我正在尝试滚动到模式弹出窗口。打开模态弹出窗口后如果按f12键作为检查元素,我想使垂直滚动到模态弹出窗口。如果我移动了垂直滚动弹出窗口,则只能移动..在CSS中怎么做? http://jsfiddle.net/sdjf48be/2/
css:
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
答案 0 :(得分:0)
打开模态时不要滚动父组件,它与您的情况相同,您还希望将垂直滚动设置为主体上的模态弹出窗口。
>因此有一个名为onAfterOpen的回调。您可以安装回调以禁用所需的元素。
在CSS中OR,例如:
.ReactModal__Body--open {
overflow-y: hidden;
}
这将在模式打开时防止身体上的溢流。
希望它会对您有所帮助。
答案 1 :(得分:0)
将overflow
从auto
更改为scroll
overflow: auto; /* Enable scroll if needed */
overflow: scroll; /* Enable scroll if needed */