I want to create CSS columns that stretch to the full height of the window, positioned between a header and a footer, while also

I am looking to create a basic HTML layout with CSS that includes a header and two columns. The right column should have a fixed width of 100px, while the left column may have varying content lengths. I want both columns to stretch to the footer. Below is the HTML code I am using:

<!DOCTYPE html>
<html>
<head>
  <title>Coming soon...</title>
</head>
<body>
<div class="wrapper">
    <div class="header">
        Header
    </div>
    <div class="content">
         This is where the dynamic content will go... it may be short or long. I want it to always reach the footer!

    </div>
    <div class="right-menu">
        This will be a menu... it should match the height of the content DIV.
    </div>
    <div class="footer">
        Footer
    </div>
</div>
</body>
</html>

Below is the CSS code I am using:

.header {
    background-color: Coral ;
    width: 100%;
}

.content {
    background-color: BlanchedAlmond ;
    float:left;
    width:100%;
    margin-right: -100px;

}

.right-menu {
    background-color: BurlyWood ;
    float: right;
    width: 100px;
}

.footer {
    background-color: Coral;
    width: 100%;
    clear: both;
    position: absolute;
    bottom: 0;
}

While creating a JSFiddle of this layout, I noticed that the content div extends under the menu. How can I prevent this? You can view the JSFiddle here: https://jsfiddle.net/dwn82s81/

Thank you in advance for any assistance. It has been a while since I worked with CSS!

Answer №1

Consider this modification for the .content style

.content {
background-color: PapayaWhip ;
float:right;
  width: 90%;
margin-right: -50px;
   
}

Answer №2

One option to consider is using display:flex if you are willing to restrict compatibility with IE.

It's important to keep in mind that this is a fairly simple configuration.

html,
body {
  height: 100%;
}
.wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.content-wrapper {
  flex: 0 0 70%;
  background: orange;
  display: flex;
}
.content {
  flex: 1 0 auto;
}
.right-menu {
  flex: 0 1 150px;
}
.header,
.footer {
  flex: 0 0 15%;
}
<div class="wrapper">
  <div class="header">
    Header
  </div>
  <div class="content-wrapper">
    <div class="content">
      Content Here will be dynamic... sometimes 1 word, sometimes 1000 words! Either way, I want to reach the footer!

    </div>
    <div class="right-menu">
      Here will be a menu... I want this to be the same height as the content DIV
    </div>
  </div>
  <div class="footer">
    footer
  </div>
</div>

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

Fixing the bug in the circle text animation

I followed the instructions in this tutorial and implemented the following code: Splitting(); * { margin: 0; padding: 0; box-sizing: border-box; font-family: monospace; } body { display: flex; justify-content: center; align-items: center; ...

Steps for incorporating a variable into a hyperlink

I'm trying to achieve something similar to this: var myname = req.session.name; <------- dynamic <a href="/upload?name=" + myname class="btn btn-info btn-md"> However, I am facing issues with making it work. How can I properly ...

Click to Rotate Angular Chevron

Is it possible to animate the rotation of a chevron icon from left-facing to right-facing using Angular? CSS: .rotate-chevron { transition: .1s linear; } HTML: <button [class.button-open]="!slideOpen" [class.button-close]="slideOpe ...

When bullet points are aligned in the middle of wrapped text instead of the top line

When using bullet points on my Joomla site for a long sentence that wraps to multiple lines, I noticed that the bullets align with the middle of the wrapped text rather than staying flush with the top line. For example, if the text wraps to 3 lines, the bu ...

Utilizing the power of JQuery AJAX and PHP to retrieve information from a MySQL database

Currently, I am facing an issue where my PHP code in the api.php file (under Joomla) is not returning the expected data. Below is the snippet of the code: <?php require_once( 'includes/defines.php' ); require_once( 'includes/framework.ph ...

Mobile viewing causing problems with website buttons functionality

While my website functions perfectly on desktop, I am facing an issue where the buttons are not working when accessed through mobile devices. Interestingly, these buttons were operating fine in a previous version of the site. Although I have made minimal ...

Responsive Image Resizing with Bootstrap for Smaller Screens

I'm struggling to resize a responsive image in Bootstrap using the carousel example on their official website. <div class="container"> <div class="other-div"> .... </div> <div id="carouselExampleCon ...

Browser inconsistencies result in varying appearance of Bootstrap selection in Firefox and Chrome

Issue with Bootstrap select rendering in Firefox and Chrome: Firefox: https://i.sstatic.net/HWEcR.png Chrome: https://i.sstatic.net/GBuDP.png Looking for ways to make the two browsers render consistently, preferably in Chrome's style. This questio ...

Solution for tables extending beyond the navbar and footer issue

My table is extending beyond the width of both the navbar and footer. Is there a way, using HTML and CSS, to make the navbar and footer expand in width to match that of the table? Most solutions I've found focus on formatting the table instead of addr ...

Prevent the page from refreshing when a value is entered

I currently have a table embedded within an HTML form that serves multiple purposes. The first column in the table displays data retrieved from a web server, while the second column allows for modifying the values before submitting them back to the server. ...

Is there a way to ensure my circular image maintains its shape when viewed on mobile devices?

On my website, I have circular images implemented using the Bootstrap 4 class rounded-circle. While they appear perfectly round on desktop, they become oval-shaped on mobile devices such as the iPhone XR. You can see the issue in this Codepen link. Here i ...

Tips for enabling autoplay for videos in Owl Carousel

I am facing an issue with implementing autoplay functionality for videos in an owl carousel. Despite trying different solutions found online, including this Owl Carousel VIDEO Autoplay doesn’t work, I haven't been able to make it work. Additionally, ...

Exploring Angular's filtering capabilities and the ngModelChange binding

Currently, I am in the process of working on a project for a hotel. Specifically, I have been focusing on developing a reservation screen where users can input information such as the hotel name, region name, check-in and check-out dates, along with the nu ...

Confirm that the CSS syntax is valid

Is there a way to validate CSS syntax by checking for specific characters like "{", "}", ";", and ":"? I have come up with four checks to ensure the code is valid, such as verifying that the number of opening and closing curly braces match, as well as the ...

Sorting Columns in JQuery Datatables

Encountering an issue with JQuery DataTables (datatables.net) where it takes 2 clicks to sort the columns when there are only 2 rows in the table. The first column sorts on the first click, but subsequent columns require multiple clicks. Despite testing th ...

css - adjust flex box to cover half of the screen and increase its size

I'm having trouble getting my CSS Flex-box to stretch the full height of the right side of the screen from the center. I want it to cover the entire right half of the screen at full height. https://www.cajsoft.co.uk/test/visitor2.html Any help with m ...

Modal overlays should consistently appear behind the loading animation

When processing something and using overlays for loading, everything works fine until I use it for a modal. The issue arises when the overlays appear behind the modal instead of in front. Is there a way to bring the overlays to the front of the modal? Bel ...

How can I prevent a horizontal scrollbar from appearing in HTML when using margin:-4px and what are some possible solutions to this

I am facing an issue with a <div> element that contains a grid row element from semantic UI. Despite setting the width to 100%, there is a small space visible on all sides of the row element. I tried using margin: -4px to eliminate the white space, b ...

Struggling to activate the link:hover transformation

At this link, you can find an example of using CSS transform to rotate links on hover, but I'm having trouble getting it to work as expected. <!DOCTYPE html> <html> <head> <style> a:hover{ ...

Angular: sending the user input to the component

I'm trying to link the value of an HTML input field to a variable 'numToAdd' in my component, and then increment the 'numToAdd' variable by 1. However, I'm facing difficulties passing the input value to the component variable. ...