【发布时间】:2020-07-20 23:22:00
【问题描述】:
我正在使用父 div 和子 div。子 div 需要能够使用滚动条调整大小,但是父 div 之外的任何溢出都需要完全隐藏或使用滚动条但没有调整大小选项。我包含了一个指向我在 JSFiddle 中工作的代码的链接。我尝试过溢出:隐藏,溢出:自动和溢出:父 div 滚动,但没有任何效果。不管是什么(即使对于溢出:隐藏),父 div 在右下角都有调整大小拖动图标选项,这正是我不想要的。如何在不可调整大小的父 div 中拥有可调整大小的子 div?
https://jsfiddle.net/9ba54kvp/1/#&togetherjs=4g2SH54efU
父 DIV = .tm
子 DIV = .overflow
.tm {
position: absolute;
top: 8%;
left: 36%;
resize: both;
right: 33%;
bottom: 50%;
border-radius: 15px;
padding: 20px;
background-color: white;
display: flex;
justify-content: center;
align-items: center;
overflow:auto;
max-height:initial;
}
.overflow {
overflow: scroll;
}
我所拥有的屏幕截图(红色圆圈中的父级调整大小):
我想要的图片(父 div 中没有调整大小选项):
【问题讨论】:
-
您在第 89 行尝试过
resize: none;吗?而不是resize: both;. -
成功了!谢谢!
标签: javascript html css