滚动在固定和绝对位置不起作用

问题描述 投票:0回答:1

滚动不适用于固定和绝对位置,我不知道还要添加什么

.modal-overlay {
  z-index:9999;
  opacity: 1;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(77, 77, 77, .7);
  transition: all .4s;
  width:100%;
  overflow-x: hidden;
  overflow-y: scroll;
}

.modal-backgroundparent {
  display:flex;
  align-items:center;
  justify-content:center;
}

.modal-background {
  z-index:10000;
  width: 350px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 10px;
}

来自 Modal 的 HTML 模板

<div class='modal-overlay'>
 <div class='modal-backgroundparent'>
  <div class='modal-background'>
   <img src="img/images.png">
  </div>
 </div>
</div>

这是我上面代码的结果,它无法在模态覆盖部分自动滚动 Example

html css modal-dialog
1个回答
0
投票

“模态背景”不需要像父级那样“固定”定位。

© www.soinside.com 2019 - 2024. All rights reserved.