CSS:y 轴的滚动条导致 x 轴的滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5768739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:22:35  来源:igfitidea点击:

CSS: Scrollbar for y-axis causes scrollbar for x-axis

css

提问by Laran Evans

Here's a screenshotof the problem.

这是问题的屏幕截图

enter image description here

在此处输入图片说明

Basically, when the scrollbar shows up for the y-axis, the width of the container doesn't expand. Instead it just creates a scrollbar for the x-axis.

基本上,当滚动条出现在 y 轴上时,容器的宽度不会扩展。相反,它只是为 x 轴创建一个滚动条。

How can I get the container to expand without creating the x-axis scrollbar?

如何在不创建 x 轴滚动条的情况下扩展容器?

回答by nonopolarity

you can give this a try for the element:

你可以试试这个元素:

overflow-x: hidden;
overflow-y: auto;

you can use scrollor autofor the overflow-y

您可以使用scrollauto用于overflow-y

here is a page with some samples: http://www.brunildo.org/test/Overflowxy2.html

这是一个包含一些示例的页面:http: //www.brunildo.org/test/Overflowxy2.html

回答by sikanderBabwani

I looked for a solution as well.

我也在寻找解决方案。

overflow-x: visible; 
overflow-y: scroll;

The above code doesn't work since the pairing of visible with either scroll or auto sets the visible property to auto. You can read more about it here: https://www.brunildo.org/test/Overflowxy2.html

上面的代码不起作用,因为可见与滚动或自动的配对将可见属性设置为自动。您可以在此处阅读更多相关信息:https: //www.brunildo.org/test/Overflowxy2.html

Looks like there's no CSS way to get what you want as far as I can tell. if someone finds another workaround, I'd be grateful to know!

据我所知,似乎没有 CSS 方法可以得到你想要的东西。如果有人找到另一种解决方法,我将不胜感激!