How to resolve CSS DIV height issue when background image is overlapping

I am working with two DIV tags that each have a background image.

<div class="content_bg">
    <div id="content">
        <div id="contentLeft">   
        </div>
        <div id="contentRight">            
        </div>
    </div>
</div>
<div class="footer_bg">
    <div id="footer">
        <div id="footerLeft">            
        </div>
        <div id="footerRight">           
        </div>
    </div>
</div>

When I manually specify the height of the content, everything displays correctly. However, if I set it to either 100% or Auto, the footer_bg ends up overlapping on top of the content_bg. Can anyone provide some guidance on this issue?

/*
====================================================================
Content Area
====================================================================
*/

.content_bg
{
    background:#dadad9 url(images/interior_content_bg_top.jpg) repeat-x center top;

}

#content
{
    width:980px;
    margin:auto;
    height:auto;   
    background:white;     

}

#contentLeft
{
    float:left;
    width:209px; 
    margin-top:50px;   
}


#contentRight
{
    float:right;
    width:770px;     
    font-family: Verdana, Arial, Sans-Serif;
    font-size: 11px;
    line-height:17px;
    border-left:1px solid;
    margin:20px 0 0 0;
}

/*
====================================================================
Footer
====================================================================
*/

.footer_bg
{
    background:#dadad9 url(images/interior_footer_bg.jpg) repeat-x center top;

}

#footer 
{
    width:980px;
    height:258px;
    margin:auto;
    background:#dadad9 url(images/interior_footer.jpg) no-repeat center top;
}
#footerLeft
{
    width:400px;
    height:50px;   
    font-family:Verdana, Arial, sans-serif;
    font-size:11px;    
    line-height:25px;
    float:left;
    padding: 20px 0 0 25px;
    color:#fff;
}


#footerRight
{
    width:100px;
    height:50px;       
    float:right;
    padding: 20px 0 0 0;
}

Answer №1

To ensure your content displays correctly, consider setting the height of all parent elements, including body and html, to 100%. Alternatively, you can set a minimum height for the content using {min-height: Npx}. The issue may be that #content is unaware of the necessary height.

Answer №2

For the code and demonstration, please refer to the fiddle: http://jsfiddle.net/4Ly7E/1/

To view the demo directly, use this link: http://jsfiddle.net/4Ly7E/1/embedded/result

Note: Since I don't have a background image, I've assumed that the border of the content and footer serve as the boundaries.

.content_bg
{
    background:#dadad9 url(images/interior_content_bg_top.jpg) repeat-x center top;
    border:1px solid red; /* for visibility */
    overflow:hidden;

}

.footer_bg
{
    background:#dadad9 url(images/interior_footer_bg.jpg) repeat-x center top;
    border:1px solid teal; /* for visibility */
    clear:both;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Explore the power of Infinity.js for optimizing the rendering of large HTML tables, complete with a detailed example using prototype

Is there a way to efficiently load/render large html tables without compromising performance, especially in Internet Explorer? I recently came across a plugin in prototype.js (https://github.com/jbrantly/bigtable/, post: , demo:) that addresses this issue ...

What could be causing the Bootstrap icon to remain the same size without changing?

Take a look at this piece of code: <div class = "banner-image w-100 vh-100 d-flex justify-content-center align-items- center"> <div class = "content text-center"> <i class="bi-chevron-compact-down bi-7x"&g ...

Transitioning the height of a webpage element from a fixed value to fit the content dynamically

I'm trying to create a div that smoothly transitions from a set height to a height based on its text content. This likely involves considering the window width, as narrower windows cause text wrapping and increase the required height. #object { w ...

How to display umlauts (åäö) using Verdana font in Internet Explorer versions 8 and 9

Encountering a strange issue on certain pages where the rendering of umlauts (åäö) appears incorrect in IE8 and IE9 at times. The encoding is utf-8 (and most of the site functions correctly, so I know it's correct). I have attempted to isolate the ...

Creating a Bootstrap layout with columns of varying heights

My current setup looks like this: <div class="row"> <div class="col-md-4">Content</div> <div class="col-md-4">Content</div> <div class="col-md-4">Content</div> <div class="col-md-4">Content&l ...

Updating a CSS variable within styled components using a React prop

I have been utilizing CSS grid to generate a flexible table with varying columns and rows that are determined by props from a parent component in React. Is there a way to update a CSS variable within a styled component (emotion) with the data received fro ...

Utilize HTML5 to send a document to Google Drive API

I'm currently developing a Google Chrome extension that utilizes the Google Drive API to upload files. While handling text files isn't an issue, I encounter errors when attempting to upload binary files. When trying to upload a file using the Fi ...

The background color of the columns is overwhelming

I would like to create a TV remote control design using bootstrap, but I am encountering some issues. The background color is overflowing and I'm unsure how to fix it. Please take a look at the code and feel free to offer any suggestions! @media scre ...

Tips for eliminating the page URL when printing a page using window.print() in JavaScript or Angular 4

Can someone help me with a function that uses window.print() to print the current page, but I need to remove the page URL when printing? I'm looking to exclude the URL from being printed and here is the code snippet where I want to make this adjustme ...

HTML display with two columns for books viewing

My Plan: I am working on incorporating HTML content from an external source into my app, displayed in a 2-column horizontal scrolling book format using a WebView element. I want it to resemble how the Edge browser presents an EPUB book, with seamless horiz ...

Adjusting Width with Javascript

My goal is to specify the width of a RadNumericTextBox that appears as an input element on the page using JavaScript. I have managed to set the width, however, the telerik controls come with built-in JavaScript functions that reset the input element' ...

Creating a fresh HTML document when logging in

Upon successfully logging in, I am unable to access the file success.html. This is my code on the client side <!DOCTYPE html> <html> <head> <title>Login Page</title> <style> //CSS Styles </style> ...

Utilizing JavaScript Function within a Modal Overlay

Displayed on the page is a table with various records fetched from a database. Each record has a button that, when clicked, opens up a corresponding record in a modal popup. This popup also allows for updating the record. While the popup is opening correct ...

analyze and respond to inquiries

Imagine there is a question titled Q1 with four radio answer options: Q1: a) b) c) d) If you were using Python, what steps would you take to locate the question, choose one of the answers, and then submit the webpage? ...

Struggling to float <aside> to the left of <article> for proper alignment?

tldr; I'm attempting to position the aside-section to the left of the article-section (similar to a sidebar/side column), but my "float" property doesn't seem to be working at all. Is there a way to achieve this without modifying the HTML code an ...

Code - Capture user's input

I have multiple input fields in my HTML document and I want to retrieve the text entered into one of them. Here's an example of one such input field: <TH> <FORM> <input name="designation" type="text" size="12" /> < ...

Tips for creating shaped images using clip-path

Can an image be clipped to match a specific shape using the clip-path CSS property? Original Image https://i.stack.imgur.com/rYeuk.jpg Desired Result with CSS https://i.stack.imgur.com/6FYfn.png ...

Tips for implementing a dynamic path in the path attribute of the single-spa-router in a single-spa react application

Here is the current code snippet: microfrontend-layout.html <single-spa-router base="/"> <main> <route default> <h1>404 route not defined</h1> </route> </main> </single-spa-router> ...

Attempting to visually create a line using a bullet in CSS

I found a beautifully designed CSS header title on another website that I fell in love with. I want to replicate the same look, but without using CSS tables like they do on that website. Here is an image of what I am aiming for: https://i.sstatic.net/qeoS ...

Synchronizing Angular icons with HTML text

Presenting my HTML code <div class="transfer-link" *ngIf="showTransferLink" qa-name="transfer-link"> <a routerLink="/Transfers"> <mat-icon>sync_alt</mat-icon> <div> Transfer </div> ...