Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Background issue

    Ok,

    I have a header with a grey background that needs to fit full width across the page and then a background on the body which will grow/shrink with the content. My question is, how do a make the header div 100% without it producing a horizontal scrollbar? I know you can hide scroll bars but just hiding the horizontal scroll doesn't work in all browsers, I need something that will work in ie8, ff, ie7, google and ie6 if poss. I don't mind doing a few hacks along the way but would rather it was clean.

    Really need your help as I can't present this design until I am confident that I can build it.

    Cheers,

    Bee
    x

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Bee_01,
    This has no scrollbar caused by #header. It does need one when you get narrower thant the width of #container.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	font: 100% "Comic Sans MS";
    	background: #FC6;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: 0;
    }
    #header {
    	height: 50px;
    	background: #ccc;
    	text-align: center;
    }
    #container {
    	height: 550px;
    	width: 800px;
    	margin: 0 auto;
    	background: #999;
    	overflow: auto;
    	font-size: 0.8em;
    }
    </style>
    </head>
    <body>
    	<div id="header">
        	<h1>This is my Header</h1>
        <!--end header--></div>
            <div id="container">
            <!--end container--></div>
    </body>
    </html>
    Does that help at all?
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes! I can't believe I couldn't see that, duh! lol, I've just done this to test it:


    <body style="text-align: center; margin: 0px; padding: 0px;">
    <div style="background-color: yellow; height: 100px;"></div>
    <div style="width: 900px; background-color: pink; margin: auto; height: 100px;"></div>
    </body>


    lol! it's amazing how things get complicated when the simple answers are missed

    Thanks

    Bee
    x

  • #4
    New Coder
    Join Date
    Oct 2009
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hello,

    Please visit the following sites to see if they can help you out:

    http://www.htmlcodetutorial.com/docu...ACKGROUND.html
    http://www.webmonkey.com/reference/HTML_Cheatsheet
    http://w3schools.com/

    Hope this helps!!!
    CoffeeCup.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •