Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:18:18+00:00 2026-05-31T17:18:18+00:00

I am building a fixed width site, 970px, centered, with a gradient as the

  • 0

I am building a fixed width site, 970px, centered, with a gradient as the surround. Originally the fixed width portion was white with several horizontal areas (menu, search area, product selection area) having a different background. This was accomplished simply with a background color of white for a div that is the next child of the body, which contained all the content of the page, and an override to the background color when needed. This worked fine.

Can I make these horizontal areas have the same background as the gradient, which will obviously be different at different places in the page? I thought I would simply keep the background-color transparent (the default) at all levels until I came to the parent of content I want white, making that parent’s background-color #FFFFFF. This works if I specify a height to the area. However, the main body of the website will be of indeterminate height, and must be white (or something other than the gradient!). Are there any techniques through which I can force an element and its contents into a white background without specifying a height on that element?

Thanks.


Thanks for the response. I should clarify with code so that the question is clear. Sorry for that.

Here is sample HTML that illustrates the problem:

<body>
<div id="Page">
    <div id="Header">
        <div id="HeaderNavigationSection">
            <div id="HeaderNavigationMenu">
                <ul>
                    <li><a href="#">Menu Item One</a></li>
                    <li><a href="#">Menu Item Two</a></li>
                </ul>
            </div>
        </div>
        <div id="HeaderBannerSection">
            <a href="#">
                <img id="CompanyLogo" alt="Company Logo" src="" height="45" width="200" />
            </a>
            <p id="BannerSloganOne">Banner Slogan One Text</p>
            <p id="BannerSloganTwo">Banner Slogan Two Text</p>
        </div>
        <div id="HeaderSearchSection">
            <div class="HeaderSearchSectionLine">
                <p class="HeaderSearchBoxLabel">Search Label One and Related Search Area</p>
            </div>
            <div class="HeaderSearchSectionLine">
                <p class="HeaderSearchBoxLabel">Search Label Two and Related Search Area</p>
            </div>
        </div>          
    </div>
</div>
</body>

First, here is CSS that works, using a page-level white background color and a section level different background color (yellow for illustration). This works throughout my code. I do not show any resets or basic settings. Note that the commented-out CSS for the #HeaderBannerSection is not needed (it appears in the code that doesn’t work, which is shown after this code).

html {
height: 100%;
background-color: #D4D4D4; /* surrogate for browser-specific gradient */}

body {
text-align: center;}

#Page {
width: 970px;
margin: 0px auto 10px auto;
line-height: 1.2;
font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
text-align: left;
background-color: #FFFFFF;}

#HeaderNavigationSection {
height: 30px;
background-color: #FFFF00;}

#HeaderNavigationMenu {
display: inline;
float: right;}

#HeaderNavigationMenu li {
display: inline;
float: left;}

#HeaderNavigationMenu li a {
display: inline;
float: left;
margin: 8px 0px 10px 0px;
padding: 0px 10px 0px 10px;}

#HeaderBannerSection {
/*width: 970px;*/
/*background-color: #FFFFFF;*/}

#CompanyLogo {
display: inline;
float: left;
width: auto;
margin: 10px 0px 10px 10px;}

#BannerSloganOne {
display: inline;
float: left;
width: 330px;
margin: 20px 0px 20px 80px;}

#BannerSloganTwo {
display: inline;
float: right;
width: 300px;
margin: 20px 10px 20px 0px;
text-align: right;}

#HeaderSearchSection {
clear: both;
height: 68px;
background-color: #FFFF00;}

.HeaderSearchSectionLine {
clear: both;}

.HeaderSearchBoxLabel {
display: inline;
float: left;
margin: 10px 0px 0px 10px;}

Here are the changes to that CSS that attempt to make the html-level background color (namely the gradient) the default, through transparency, except where specifically overridden where desired (in this example, for the #HeaderBannerSection (with code from above commented out as needed)):

#Page {
width: 970px;
margin: 0px auto 10px auto;
line-height: 1.2;
font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
text-align: left;
/*background-color: #FFFFFF;*/}

#HeaderNavigationSection {
height: 30px;
/*background-color: #FFFF00;*/}

. . .

#HeaderBannerSection {
width: 970px;
background-color: #FFFFFF;}

. . .

#HeaderSearchSection {
clear: both;
height: 68px;
/*background-color: #FFFF00;*/}

This code does not work. The background-color for the section that should be white instead remains the gradient. This is true unless I specify a height for the section, then it all works. But I won’t be able to specify the height for the main section (not shown) unless I do a jQuery to determine rendered height and then do a jQuery css height setting (not ideal, and haven’t even tried it yet to see if it works). Incidentally, the offending code does work in IE6 and IE7 (at least as rendered in Expression Web 4 SuperPreview).

Thanks again for any help you can give me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:18:20+00:00Added an answer on May 31, 2026 at 5:18 pm

    For your banner section try this jsfidle

    the min-width property forces the div to have a specific minimum width if the content inside it is not enough to fill it (it will be the specified width by default until the content in it is so much that the div has to expand)

    I’ve changed the background colour so that you can see the actual div @ work
    feel free to change to #FFFFFF once you are sure you have gotten it correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a site (with jQuery 1.4) which has a floating (fixed position) basket.
I'm building a site with a home page that has a DIV positioned (fixed)
I am currently building a footer element that fixed at the bottom of the
building a site using PHP and MySQL that needs to store a lot of
i'm building a portlet style site with tabs using jquery 1.4.2, and jquery ui
I've been playing around with http://nixboxdesigns.com/projects/jquery-lavalamp/ for a navigation menu on a new site
Okay so I'm building a CSS drop down menu similar to that on ESPN's
I am building my first PHP/MySQL site and i would like to return search
I am building an application where the datamodel is fixed, but people (or just
I am building an online retail store that has a fixed amount of clothes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.