Creating a layout with a CSS div that has a height of 100

I've been utilizing this code to design the layout of my website. However, I've encountered an issue where the "left" and "right" divs are not displaying on the screen (they only show up when I set their height in pixels, not in percentages). Any suggestions on how I can resolve this problem?

<!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>
    <title>Test</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <style type="text/css" media="screen">
    * { 
        margin: 0; 
    }

    html, 
    body { 
        height: 100%; 
    }

    #wrapper {
        min-height: 100%;
        height:     auto !important;
        height:     100%;
        margin:     0 auto -44px; /* -44px being the size of the footer */
    }

    #header { 
        height: 86px; 
    }

    #footer, 
    #push {
        height: 44px;   
    }

    #left
    {
      width:8px;
      width:100%;
      background-color:blue;
      float:left;
    }


    #right
    {
      width:8px;
      width:100%;
      background-color:blue;
      float:right;
    }

    #left: first,
    #right: first,
    {
    content: "";
    height: 0;
    clear: both;
    display: block;
    }
    </style>
</head>
<body>
    <div id="wrapper">
        <div id="header">header</div>
        <div id="content">
         <div id="left"></div>
         content
         <div id="right"></div>
        </div>
        <div id="push"></div>
    </div>
    <div id="footer">footer</div>
</body>
</html>

Answer №1

The Strategy for Success:

To make the necessary adjustments, focus on altering the following classes:

#content {height: 80%;}
#left, #right {width: 30%; height: 100%;}

Below is the updated code along with the entire file:

<!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>
    <title>Test</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <style type="text/css" media="screen">
    * { 
        margin: 0; 
    }

  html, 
  body { 
      height: 100%; 
  }

  #wrapper {
      min-height: 100%;
      height:     100%;
      margin:     0 auto -44px; /* -44px being the size of the footer */
  }

  #header { 
      height: 86px; 
  }

  #footer, 
  #push {
      height: 44px;   
  }

  #left
  {
    width:8px;
    width:30%;
    background-color:blue;
    float:left;
  height: 100%;
  }


  #right
  {
    width:8px;
    width:30%;
    background-color:blue;
    float:right;
  height: 100%;
  }

  #left: first,
  #right: first,
  {
  content: "";
  height: 0;
  clear: both;
  display: block;
  }
  #content {
  height: 80%;
  }
  </style>
</head>
<body>
  <div id="wrapper">
      <div id="header">header</div>
      <div id="content">
       <div id="left"></div>
       content
       <div id="right"></div>
      </div>
      <div id="push"></div>
  </div>
  <div id="footer">footer</div>
</body>
</html>

This approach has been successful in resolving the issue:

I trust this provides you with a solution! :)

Answer №2

Following

<div id="footer">footer</div>

insert

<br style="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

Unable to retrieve data with Selenium web driver

I have been attempting to extract the product description from a webpage using ID and tagname. However, when I try to print it out, the result is coming up empty. I am certain that I have used the correct locators to find the element. Page Source < ...

Troubleshooting: Unable to retrieve all checked values using jQuery

Can someone please assist me with why it is returning an empty array? Thank you in advance. Feel free to check out the code at . Sample Code : function search(){ var pettype = []; $(".pettype :checked").each(function(){ alert($(this).val() ...

Having difficulty leveraging the full capabilities of the Jquery.load() function

I'm currently facing an issue where the results I want to display to the user are not filtering properly based on their selection. I've been using GET on the same page (users.php?rid=) to process this, but for some reason, it seems to be loading ...

mismatch between margin-left and auto not aligning

Having trouble with margin-left: auto not working 1- Looking to create a header with an image and a navbar 2- Want two unordered lists in the navbar 3- Trying to position one list on the left side and the second on the right side When I use margin-left: 8 ...

Arranging two tables, one slightly misplaced from the other

I have been searching through various websites, but I cannot find a solution to the specific issue I am facing. I am attempting to create a web page with a table aligned to the left side while keeping the rest centered. However, when I align items in the ...

Exploring the world of web scraping using R's XML package with the powerful xpathS

I need help extracting the names of shopping malls from a specific website. The URL is provided here: After examining the html code, I noticed that the mall names are stored under the "h5" tag. I tried to extract the text using the following codes, but it ...

Arrange a div element among the descendants of a neighboring div

I am working with a div that is generated by a library. This div contains 2 child divs with varying heights, which can change based on the API response and the width of the browser window. My goal is to display another div (my-div) between top-bar and bot ...

How can I prevent a nested Table from inheriting the style of the parent table?

Just to clarify, I'm not using tables or any other styling methods like that on my page. I have a simple table that lists services, prices, and PayPal buttons for adding to the cart. While everything is functioning properly and looks good, there are ...

Why isn't my li:hover responding the way it should?

Check out this Fiddle When the mouse hovers over the element, an opaque "cloud" appears and I want to completely hide the underline that is normally displayed. The underline is created by using a border-bottom on the parent div. .element_style{ width ...

Using the combined power of CSS and jQuery to create dynamic visual effects based

Having some trouble figuring out why this code isn't functioning as expected... I've got a bunch of DIVs that have the class .rightColumnButton. Some of them currently have a height set to 30px: .rightColumnButton{ height:30px; width:206px; mar ...

The HTML source code in the browser varies from the output obtained through Python requests

I've noticed a discrepancy between the HTML source code displayed in my browser and the code I receive when using Python's requests.get function. You can see the image depicting this issue at the following link: Any thoughts on why this might be ...

Having trouble with an AJAX request to display a template in Flask

Imagine having two radio buttons labeled 1 and 2, along with some text at the bottom of a webpage. Initially, the text value is set to -1 and no radio buttons are selected. If one of the radio buttons is clicked, the text value should change to either 1 or ...

The utilization of the Open Sans font family results in certain alterations to the user

Currently, I am working on developing a button widget using react. I have utilized the 'Open Sans' font family for the HTML body in order to maintain consistent UI styling. However, some of the styling elements break down when the 'Open Sans ...

difficulties with struts2 user interface elements

Can anyone explain why the s:textfield is being positioned at the bottom when inserted among other HTML elements within a form? And what steps can be taken to resolve this issue? <label><span class="required">*</span>First name</label ...

Customize Bootstrap modal width to suit content dimensions

Is there a way to adjust the width of the modal to fit its content without setting a fixed value? I want to avoid having a horizontal scrollbar. I attempted setting the overflow-x property but it didn't work. If possible, I'd prefer not to use jQ ...

What could be causing the failure of this web component using shadow DOM when the HTML code includes multiple instances of the component?

Recently, a question was raised on this platform regarding the use of Selenium to access the shadow DOM. Curious about this topic, I delved into the MDN article Using shadow DOM and decided to replicate the code on my local machine. Surprisingly, it worked ...

Resolving AJAX requests within a loop

I am working with a JSON file that contains widgets {"widgetname": "widget1", "widgetID": "FJRH585fKFJN234NC"} As I iterate through the JSON, I generate HTML for each widget object. $.ajax({ url: "get_json.php", data: {action: "get_widgets", ...

What is the process for swapping out a file input tag with a specific file already chosen?

As I attempt to process a file one line at a time, I came across this helpful solution. Unfortunately, the method involves using a file input tag to choose a file for reading. I am in search of a way to bypass the file input tag and specify a file in advan ...

Receive a pair of distinct arrays through a text field submission

I have a form on my website with a single textarea input. Visitors can enter text in the textarea in the following format: 5x Blue Flower 2 Red Flower 3* Yellow Flower Purple Flower I need to extract two arrays from this input - one for the quantity an ...

NoReverseMatch error encountered following inclusion of the Favorite button

I am new to the Django framework and currently following a tutorial. However, I encountered an error when trying to add an input button for favorites on my detail.html page: Error during template rendering In template C:\Users\leo8\Desktop ...