如何制作可滚动的弹出框?

How to make scrollable pop up box?

https://codepen.io/anon/pen/dWaWor

当我单击按钮时 "Creation Process" 我无法在灯箱中滚动。

灯箱有一个固定的位置,因为当我使用 absolute 时,背景会乱七八糟。灯箱是白色背景。

<section id="lightbox">
   <i id="x" class="fa fa-times-circle"aria-hidden="true"></i>
   <p class="large">hi</p>
</section>

>

#lightbox {
  height:100%;
  width:100%;
  display: none;
  position: fixed;
  top:0;
  left:0;
  background: #fff;
  z-index:1;
}

>

 var btn_process = document.getElementById('creation-process');
 var lightbox = document.getElementById('lightbox');
 var x = document.getElementById('x');

 btn_process.onclick = function () {
    lightbox.style.display = 'block';
};

x.onclick = function () {
    lightbox.style.display = 'none';
}

试试这个代码。这就是你想要的吗?

#lightbox {
    height: 80%;
    width: 80%;
    display: none;
    position: fixed;
    top: 6%;
    left: 10%;
    background: #fff;
    z-index: 1;
    overflow:auto;
}

我添加了 overflow auto,所以在较小的屏幕上,灯箱将是一个滚动条。

如果这就是您想要的,请告诉我。

更新:

要仅在 #lightbox 上滚动,则可以将溢出自动添加到 CSS。

#lightbox {
    height:100%;
    width:100%;
    display: none;
    position: fixed;
    top: 0%;
    left: 0%;
    background: #fff;
    z-index: 1;
    overflow:auto;
}

如果你只需要垂直滚动,使用overflow-y: scroll !important;

#lightbox {
height:100%;
width:100%;
display: none;
position: fixed;
top: 0%;
left: 0%;
background: #fff;
z-index: 1;
overflow-y: scroll !important;

}