Html 移除 CSS 中的水平滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12156468/
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-29 02:31:22  来源:igfitidea点击:

Remove horizontal scroll bar in CSS

htmlcss

提问by designersvsoft

I am using a facebook like button on my web page. I need it to align at the right side of the page. But there is a horizontal scroll bar displaying.

我在我的网页上使用类似 facebook 的按钮。我需要它在页面的右侧对齐。但是有一个水平滚动条显示。

Please see the fiddle http://jsfiddle.net/u4kMs/

请看小提琴http://jsfiddle.net/u4kMs/

I couldn't find out what causes this. How to fix this?

我无法找出是什么原因造成的。如何解决这个问题?

回答by blasteralfred Ψ

to disable scroll, try something like;

要禁用滚动,请尝试类似的操作;

.your_div_class{
    overflow-x: hidden;
    overflow-y: scroll;
}

回答by Christoph

The scrollbar appears because the content is too wide for your screen.

出现滚动条是因为内容对于您的屏幕来说太宽了。

Just omit the width on the divelement, it will auto-expand to 100% of it's parent. Floating the facebook button to the right like you already did should then align the button correctly without scrollbar.

只需省略div元素的宽度,它就会自动扩展到其父元素的 100%。像你已经做的那样向右浮动 facebook 按钮应该然后正确对齐按钮而没有滚动条。

If you don't get a satisfying solution you can still declare overflow:hiddenon the containing div to supress the scrollbars.

如果您没有得到满意的解决方案,您仍然可以overflow:hidden在包含的 div 上声明以抑制滚动条。

This would be the result: http://jsfiddle.net/poikl/u4kMs/8/

这将是结果:http: //jsfiddle.net/poikl/u4kMs/8/

回答by David Sigley

It's because the frame is too small for the width that you have set on the top div

这是因为框架对于您在顶部 div 上设置的宽度来说太小了

<div style="margin-left:auto; margin-right:auto; width:980px;">

So when this is on your web page yo shouldn't get the horizontal scroller. If you do, then consider changing the above width

所以当它出现在你的网页上时,你不应该得到水平滚动条。如果你这样做,那么考虑改变上面的宽度

回答by DonCallisto

Try thisand remember to put the "right-aligned" div beforethe left-aligned div, even the right div have to be "after" graphically speaking.

试试这个,记得把“右对齐”分区左对齐DIV,即使是正确的DIV必须讲图形“之后”。