javascript - Smiplebar Scroll 不适用于网格 css 中的嵌套 div
问题描述
我在网格上使用 simplebar 滚动,它适用于所有 div 父和子,但在子上它不显示滚动。我也尝试使用 flex,结果相同。请帮我。
$('.myElements').each(element, new SimpleBar());
.parent{
width:50%;
height:200px;
overflow:auto;
display:block;
}
.container{
display:grid;
grid-template-columns: repeat(2, 1fr);
grid-gap:20px;
}
.child{
background:#ddd;
height:100px!important;
overflow:auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="parent" data-simplebar>
<div class="container">
<div class="child" data-simplebar>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="child" data-simplebar>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="child" data-simplebar>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="child" data-simplebar>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
解决方案
推荐阅读
- python - How to change color of graph and draw vertical shaded rectangle in matplotlib pyplot?
- javascript - “catching” errors in embedded youtube videos
- php - The Get method is not supported for this route .supported methods:POST in prudiction
- reactjs - Sharing code between React, React-Native and Electron
- python - Send logs from docker container to Windows host
- python - IndexError on 3-dimensional arrays
- javascript - How to convert cURL to axios
- node.js - Why does my function return "undefined" but works with console.log please ? How to solve that please?
- python - 无界二分搜索(找到单调递增函数变为零的点)
- php - 只获取号码,不带任何文字