Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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;


This is cool if you're using php

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

- JH

Chris Shaw
Chris Shaw
26,676 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.

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.