html - 在另一个 div 上启用 Readonly DIV 的滚动
问题描述
我有一个包含一些内容的 DIV,需要处于只读模式,所以我将它与另一个 DIV 重叠并设置光标:无拖放。
这很好用,使我的内容只读,但它也不允许用户滚动内容 DIV。
我怎样才能让我的内容 DIV 可滚动。
.roDiv {
position: absolute;
height: 100%;
width: 100%;
cursor: no-drop;
z-index: 1000;
}
<div class="roDiv"></div>
<div id="content" style="overflow-y:scroll; height:90px;">Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>and this division should be scrollable<br/> as the content can be longer</div>
解决方案
无需与另一个重叠,只需添加一些 CSS 并使其无法检测:
#content {
cursor: no-drop;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
}
<div id="content" style="overflow-y:scroll; height:90px;" >Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>
Content goes here, <br/>and this division should be scrollable<br/> as the content can be longer</div>
推荐阅读
- flutter - Flutter中直接使用不带MaterialApp的Navigator类(初始化)
- javascript - 无法在对象数组上使用映射函数
- python - TensorFlow QAT 如何获得量化权重
- c# - 在 Azure BlobClient 上设置 ContentType 而不擦除 ContentHash 等属性
- excel - 在基于公共列比较两列之间的值时需要帮助
- python - Python Pandas - 使用 .loc 在多列上使用 AND 和 OR 进行选择
- git - IntelliJ IDEA Ultimate Edition - 更新项目后无法查看 Git 提交
- ios - 使用 PageViewController 运行 WKWebView 时,滑动不起作用
- reactjs - 如何从使用效果中访问状态变量数据?
- memory-management - c API之excelDNA内存管理