Solved

Width of header/footer repeated image when window is shrunk

Posted on 2010-08-24
9
382 Views
Last Modified: 2012-05-10
Hey all,

I have this interesting scenario and i'm wondering if someone could assist me since it's been something that even stumped my buddy who works in web dev.

I don't like giving out links usually so i will explain this problem using images.

My concern is when I minimize the browser below the initial width of my container; upon scrolling to the right, i notice that the repeated bg image i'm using for the header and footer are eventually stuck once i've scrolled beyond the new browsers width.

My width is set to 100%, so my css is just doing what it's told, however i'm wondering if anyone has a solution to this problem that I've seemed to had time and time again on other sites.
1.jpg
2.jpg
3.jpg
0
Comment
Question by:Arka3L
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 21

Expert Comment

by:chapmanjw
Comment Utility
Using CSS try setting the width of HTML, BODY, and the header container to 100%.

html
{
width: 100%;
}

body
{
width: 100%;
}

#header
{
width: 100%;
}
0
 
LVL 1

Author Comment

by:Arka3L
Comment Utility
Those are my current attributes.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
Without seeing the code and debugging using FireBug, it may be a little tricky to find your problem!

0
 
LVL 11

Expert Comment

by:level9wizard
Comment Utility
That is not normal browser behavior - my first thought is to ask if you have validated both your HTML and CSS using a valid DOCTYPE ? [see w3.org]

Second, this can sometimes appear if there is a containing div (often used for content) that either applies this repeating background, or has its own interfering with it.

For the repeating bg, where is it applied? The <body>, or in <html> or in another containing <div> ?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:Arka3L
Comment Utility
Yes, of course, i always validate my code.

The main gradient you see in the first picture is set in the body, however the header is completely separate from the container div.

My header div is by itself and spans a width of 100% with its own bg image. Below that the container begins, so they are two separate divs altogether and one is not contained in the other.

I've decided to upload my files and remove any particular wording. The footer is not included, but thats not important.
urology.zip
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
Comment Utility
Try adding:

    min-width:900px;

to your CSS rule for #header, within style.css

#header {

	width: 100%;

	height: 132px;

	background: #fff url(../images/header_bg.gif) repeat-x top left;

	top: 0px;

	min-width:900px;

}

Open in new window

0
 
LVL 11

Expert Comment

by:level9wizard
Comment Utility
Arka3L>>The main gradient you see in the first picture is set in the body, however the header is completely separate from the container div.


I don't really see the need to have two separate background containers for that (one in header, one in body). Just take a single 1px-wide slice as high as needs be to grab both the header menu bit and the fading gradient and repeat it on body. Then, you can define an overlaying div for the header with Background: transparent. As for the following content boxes ( the ones with "serving your health" and "Welcome to Urology") just give them a margin:0 auto; to center, and apply the background color as needed.
0
 
LVL 1

Author Closing Comment

by:Arka3L
Comment Utility
Most of the time is the obvious solutions that work best!
0
 
LVL 11

Expert Comment

by:level9wizard
Comment Utility
Arka3L>>Most of the time is the obvious solutions that work best!

I would test that in several browsers (Opera,Chrome,IE,FF,etc) - I have had unexpected results with min-width and min-height unless using the min-height fast hack:
http://www.dustindiaz.com/min-height-fast-hack/
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now