Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove horizontal scroll bar in CSS

Tags:

html

css

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.

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

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

like image 385
designersvsoft Avatar asked Aug 28 '12 09:08

designersvsoft


People also ask

How do I stop horizontal scrolling in web design?

You can also set the overflow-x CSS property to hidden, which prevents child content from wrapping within its container but turns off sideways scrolling. Another solution is to set the width of child elements to 100%.

How do you stop a scroll in CSS?

Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.

How do I scroll horizontally in CSS?

For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.


2 Answers

to disable scroll, try something like;

.your_div_class{
    overflow-x: hidden;
    overflow-y: scroll;
}
like image 118
Alfred Avatar answered Oct 23 '22 11:10

Alfred


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

Just omit the width on the div element, 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.

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

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

like image 36
Christoph Avatar answered Oct 23 '22 10:10

Christoph