Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to limit the horizontal  scroll when a website is viewed in a browser.

Posted on 2009-05-03
6
Medium Priority
?
500 Views
Last Modified: 2012-08-14
How can you limit the horizontal scroll when someone visits your website? If you go to cnn.com
or apple.com  or http://www.marketwatch.com for example there is no horizontal scroll bar at all. Some sites have horizontal scroll bars, but you can only scroll to the right about a half an inch.

I ask this because I have created a website. The website has a banner image that is
1260 x 170 pixels. It looks good, but when viewed in a browser, their is a horizontala scroll bar that allows the application user to scroll horizontally to the right by about two inches.  

Also if the website is viewed on a really wide screen, the end of the banner image is visible and looks too short.

Attached is sample banner image, and a css file(Renamed to .txt file so that I could upload it to this forum). Although if you remove the reference to the banner image, you will see that the problem still exists.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <link rel="stylesheet" href="css/mainster.css" type="text/css" media="screen" charset="utf-8" />
</head>
<body id = "twoColLayout">
 
<div id="maincontainer">
<div><img id="Img1" src="images/GMRBanner.jpg" runat="server" alt="" width="1260" height="170" /></div>
 
<div id="navAndSearch">
 
 
</div>
 
<br />
 
 
 
</div> <!-- Wrapper Div -->
 
</body>
</html>

Open in new window

GMRBanner.jpg
mainster.txt
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 13

Expert Comment

by:Brian Withun
ID: 24292190
see if this gets you any further along:

body {
   overflow: hidden;
}

0
 
LVL 13

Accepted Solution

by:
Brian Withun earned 1840 total points
ID: 24292199
Or maybe this is more like it:

body {
   overflow-x: hidden;
}
0
 
LVL 43

Assisted Solution

by:David S.
David S. earned 80 total points
ID: 24292299
What I would do is use multiple images, so that the logo would always be shown but more or less of the rest would be visible depending on the width of the viewport.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:brgdotnet
ID: 24292542
bhwithun is correct. I need to straighten out something before I award the points. Another expert helped me and I told him he was wrong. He offered the same suggestion as bhwithun. So give me a day or two before I straighten out my mistake. Thanks!
0
 
LVL 16

Assisted Solution

by:hankknight
hankknight earned 80 total points
ID: 24293429
WARNING!

It is worth mentioning that it can be dangerous to use:

       body {
          overflow: hidden;
       }
or
       body {
          overflow-x: hidden;
       }

It is like it is like amputating your leg because you have an overgrown toe nail.  If you cut off your leg, you will no longer have an overgrown toenail, however you won't have a leg either....  It may solve the symptom but the cure could be worse than the disease.

If you use either of these ideas, other good content could TOTALLY DISAPPEAR!

Instead, you should find the specific problem (in this case the banner) and apply overflow conditions ONLY to it.

Otherwise other content could also disappear without notice.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <style type="text/css" media="screen">
 
 
body {
}
 
body{
margin:0;
padding:0;
line-height: 1.5em;
height: 850px; /* Height of both columns static */
background: #FFFFEE; /* Give it that faded yellow */
}
 
/* Temporary */
..DivContent
{
position:absolute;
left:105px;
width:700px;
height:600px;
top:220px;
background-color: rgb(192,0,0);
overflow: auto;
}
 
b{font-size: 110%;}
em{color: red;}
 
#topsection{
background: #EAEAEA;
height: 50px; /*Height of top section*/
}
 
#topsection h1{
margin: 0;
padding-top: 5px;
}
 
#contentwrapper{
float: left;
width: 100%;
}
 
#contentcolumn{
margin-left: 200px; /*Set left margin to LeftColumnWidth*/
}
 
#leftcolumn{
float: left;
width: 200px; /*Width of left column*/
margin-left: -100%;
background: #CCCCCC;
height: 850px; /* Hieght of both columns static */
}
 
 
 
#footer{
clear: left;
width: 100%;
background: #3399FF;
color: #FFF;
text-align: center;
padding: 4px 0;
}
 
 
#footer a{
color: #FFFF80;
} 
                 
 
 
 
 
 
 
.caption 
{
font-family: Arial, Sans-Serif;
background-color: #5D7B9D;
color: Red;
font-size: 12pt;
}
 
                     
.contain  {
overflow: hidden;
}
 
 
</style>
</head>
<body id = "twoColLayout">
 
<div id="maincontainer">
<div class="contain"><img id="Img1" src="images/GMRBanner.jpg" runat="server" alt="" width="1260" height="170" /></div>
 
<div id="navAndSearch">
 
 
</div>
 
<br />
  
</div> <!-- Wrapper Div -->
 
</body>
</html>

Open in new window

0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 31577407
bhwithun is correct. The other two answers were about B- quality. But I will give 20 points to each participant who at least tried to answer my question
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question