[HTML] How to stop horizontal scrolling?

Newbie Spellweaver
Joined
Apr 22, 2010
Messages
22
Reaction score
1
Hi there, i wouldve used the search box but i dont know what to type in. Anyway, im making a website for a group thing, i would like to know. How do i make the webpage all one size so there is no horizontal scrolling? (Like ragezone has no horizontal scrolling, only vertical)

If you dont understand this reply back and ill try and word it more efficiently.
Thanks
Mark.
:sneaky2:
 
Last edited:
Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
Re: [HTML] Website help needed.

Just follow these and someone might be able to actually help you


 
Newbie Spellweaver
Joined
Nov 24, 2008
Messages
19
Reaction score
15
Code:
<style>
 body{
  overflow-x: hidden;
 }
</style>
 
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
aah he means like the top...
The background?
Code:
body {
background-image: url("http://forum.ragezone.com/images/zoomtube/gradients/body.gif");
background-repeat: repeat-x;
}
 
Joined
Nov 17, 2008
Messages
800
Reaction score
1,392
If you're looking for a method to designing a web page that will not need horizontal scrolling, use a design that is around 900px in width. This way it won't be too thin, and just about every monitor will be able to fit it in their screen.
 
Custom Title Activated
Loyal Member
Joined
Apr 9, 2007
Messages
2,408
Reaction score
256
Standard used to be 960px, nowadays it's fine to use 1140px.

This isn't true...
I still know people that need 960px
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
I was taught in high school to fit the 800px resolutions (around 780px including borders & margins). Lol.. This sure changed.

A strict width is easy.. Just do the math and make sure the DIVs never exclude the standard width (which seems to continuously increase over the years).

960 or 1140 seem good (but adjust for the browser and vertical scroll bar about 20px. Most developers assume the browser is maximized, so test it maximized.

If you want the site to work well all the time no matter what width the browser (to a point, the size of an element can cause a horizontal scroll despite any CSS/HTML sizing on it's parent..)

Anyway, you can use percentages in CSS (and html..)

Code:
<html>
<head>
<title>Hello Percentage Width..</title>
<style type="text/css">
.my_holder_class {
    width: 80%;
    margin: 0 auto 0 auto; /* top right bottom left.. */
    
}

.my_header_class {
    width: 100%;
    text-align: center;
}

.my_body_class {
    width: 100%;
    margin:-11px; /* subtract border and padding to correct placement */
    border: 1px solid #000; /* width style color.. */
    padding:10px;
    
}

.my_footer_class {
    width: 100%;
    text-align:center;
    font-weight: bold;
}
</style>
</head>
<body>
<div id="header" class="my_header_class">
  <h1>Hello World!</h1>
</div>

<div id="holder" class="my_holder_class">

  <div id="body" class="my_body_class">
    <h3>Sub title</h3>
    <p>This is some content on my site...</p>
  </div>

</div>

<div id="footer" class="my_footer_class">
  <p>© My Website 2011</p>
</div>
</body>
</html>
Notice the 100% declared in my_body_class is relative to it's parent. So it's border shows us 80% of the total browser width, no matter what size the window.

Also notice you have to subtract the margin by padding+border or the percentages will be thrown off in standards-compliant browsers.

but percentages get annoying with added complexity... Fixed width is much simpler. and only requires basic (very basic, add/subtract) math.
 
Last edited: