Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

José Manuel Martínez López
José Manuel Martínez López
18,133 Points

How can i disable the horizontal scrollbar?

I have an image as background and it has some extra space that i don´t need.

1 Answer

John Hartney
John Hartney
2,893 Points

I use this

html { 
background: no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Reference

This is cool if you're using php

$("body").css("overflow", "hidden");

- JH

Chris Shaw
Chris Shaw
26,650 Points

Please bare in mind that you don't need JavaScript to achieve this, CSS can do this and it's much faster than any piece of JavaScript.

html,
body {
  overflow-x: hidden; /* refers to the horizontal axis */
}
John Hartney
John Hartney
2,893 Points

Thanks Chris, I thought that was php, oops!

If it's well supported, css seems to be the best way to go with most things, at least thats what I'm learning since I joined treehouse

It's interesting to note how many ways you can do the same thing, though even more interesting to know what is the most efficient.