如何将卷轴从组成部分的右边界移开
在应用程序中,我以表格显示数据。
主列分组为代表父组件的红色帧。我想在可滚动区域外面的右侧添加一个额外的摘要列。
我尝试的是使用Overflow-X:可见
,但它无法如下所述: https://www.brunildo.org/test/test/overflowxy2.html
使用纯HTML/CSS解决方案处理?
.parent {
border:2px red solid;
height:400px;
overflow-y:scroll;
overflow-x:visible;
width:500px;
}
.child {
background:green;
height:50px;
margin-bottom:2px;
width:600px;
}
<div class="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
In an application I display data in table form.
The main columns are grouped in the red frame representing the parent component. I want to add an additional summary column on the right outside the scrollable area.
what I tried is to play with the overflow-x:visible
, but it doesn't work as explained here :
https://www.brunildo.org/test/Overflowxy2.html
How can I handle this with a pure html/css solution ?
.parent {
border:2px red solid;
height:400px;
overflow-y:scroll;
overflow-x:visible;
width:500px;
}
.child {
background:green;
height:50px;
margin-bottom:2px;
width:600px;
}
<div class="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
i am giving sample . you do like this
i am giving sample . you do like this
我认为您不能拥有它,以便至少不仅在HTML和CSS上,滚动条不在正确的边缘。这是我最接近的
I don't think you can have it so that the scrollbar isn't on the right edge, at least not just with HTML and CSS. Here is the closest I could get
最后,我找到了适合我的滚动条问题的解决方案。
必须进行以下修改:
width
必须等于孩子的y
必须设置为覆盖。
200px
的卷轴的宽度
。边界权利:190px
和background-clip:content-box
的拇指。我认为它仍然可以优化
Finally, I found a suitable solution for my scrollbar problem.
the following modifications are necessary:
width
of the parent must be equal to that of the childoverflow-y
of the parent must be set tooverlay
.width
of the scrollbar of200px
.border-right: 190px
and thebackground-clip: content-box
.I think it can still be optimized
如果要在一列中显示数据,请列表,
&lt; ul&gt;
或&lt; ol&gt;
在语义上是正确的选择。要在多个列中显示数据,与此处一样,您需要一个&lt; table; gt;
。If you want to display data in one column, lists, either
<ul>
or<ol>
are ususally the semantically correct choice. To display data in more than one column, as it's the case here, you need a<table>
.