0

Having trouble with a horizontal scroll bar that pops up.

My page is set up like so:

<html>
<head></head>
<body>

<article>
</article>

</body>
</html>

My css

article {
    width:100%;
    margin:0px auto;
    padding:25px;
}

I'm also using Yahoo's Reset CSS. The trouble is the 100% on Article is giving me a horizontal scroll that I can't get rid of. I want it to stretch the length of the window with just a bit of space on the right and left.

Slick23
  • 5,827
  • 10
  • 41
  • 72
  • It looks like the article is wider than a parent element. Try setting the body to 100% width and see if that helps. – Alex Morales Jan 15 '12 at 14:29

3 Answers3

3

The width property sets the width of the content, excluding padding, so the total width required by the element is all of the available width plus 2 times 25px.

Omit width: 100% (so that the default width: auto will be used).

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
2

This worked for me, I was having the same problem only in Firefox

body {
     overflow-y: auto;
     overflow-x: hidden;
}
amandathewebdev
  • 259
  • 5
  • 22
  • I don't believe you can actually set one to auto and the other to hidden, per https://stackoverflow.com/a/6433475/1449525 – Patrick May 06 '19 at 13:09
0

100% Width + 25px padding = container.width+25px. Just add article { overflow-x:hidden } and it should hide it.

Andres I Perez
  • 75,075
  • 21
  • 157
  • 138