html - 在另一个 div 上启用 Readonly DIV 的滚动

标签 html css division readonly

我有一个 DIV,其中包含一些需要处于只读模式的内容,因此我将它与另一个 DIV 重叠并设置了 cursor:no-drop。

这很好用,使我的内容成为只读的,但它也不允许用户滚动内容 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>

关于html - 在另一个 div 上启用 Readonly DIV 的滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52075718/

相关文章:

html - 通过 apache 服务器查看时,我的 django 管理页面没有 css

html - 没有边框的 li 元素下的额外白线

html - 与行内元素垂直对齐

jquery - 自动调整大小的动态文本以填充固定大小的容器

html - 文本溢出 : ellipsis doesn't work after line break in Internet Explorer

python - 继续进行整数除法减半,直到 x=1

javascript - 更改页面 Javascript 时保持链接样式

html - IE6 CSS 工具提示未出现

html - float div不 float

optimization - 将整数除以 3 的最快方法是什么?