Keep the columns at a full 100% height while accommodating dynamic content

Is it possible to have a two-column layout, where one column remains static while the other dynamically generates content, while ensuring both columns are 100% the height of the wrapper?

https://jsfiddle.net/t1h4vngv/1/

HTML

<div class="wrapper">
  <div class="col left">
    Static stuff
  </div>
  <div class="col right">
    Dynamic Stuff
  </div>
</div>

CSS

html,
body,
.wrapper,
.col {
  height: 100%;
  margin: 0;
  padding: 0;
}

.col {
  float: left;
}

.left {
  background: lightblue;
}

.right {
  background: lightgreen;
}

.thing {
  width: 200px;
  height: 100px;
  background: beige;
  border: 2px solid grey;
}

JS

var el = '<div class="thing">Hi</div>'
var $right = $('.right')
for (var i = 0; i < 20; i++) {
  var $el = $(el);
  $right.append($el)
}

Answer №1

Using Flexbox, you can achieve the following:

var el = '<div class="thing">Hi</div>'
var $right = $('.right')
for (var i = 0; i < 10; i++) {
  var $el = $(el);
  $right.append($el)
}
html,
body,
.wrapper,
.col {
  min-height: 100%; /* ensure minimum height */
  margin: 0;
  padding: 0;
  display: flex;
}

.col {
  display: flex;
  flex-direction: column;
}

.left {
  background: lightblue;
}

.right {
  background: lightgreen;
}
.thing{
  width:200px;
  height:100px;
  background:beige;
  border:2px solid grey;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
  <div class="col left">
    Static content
  </div>
  <div class="col right">
    Dynamic content
  </div>
</div>

Answer №2

The issue arises from using float. When trying to make two floated elements the same height, you may encounter difficulties. Refer to this ticket for more information: HTML/CSS: Making two floating divs the same height

Adding content to the right column should resolve the problem. Give it a try and see if it works. Hope this helps! ;)

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

On what occasion is a DOM element considered "prepared"?

Here's a question that might make you think twice: $(document).ready(function() { }); Sometimes, the simplest questions lead to interesting discussions. Imagine having a list of elements like this: <body> <p>Paragraph</p> < ...

The React page is stuck in a perpetual cycle of reloading every single second

After developing an invoice dashboard system using React, I encountered a recurring issue with a similar version of the app built on React. Even after commenting out all API calls, the useEffect(), the page kept reloading every second. Any advice or sugge ...

Using jQuery to eliminate repetitive line dividers in a document

Is there a way to remove duplicate dividers in my bootstrap pull-down menu (MVC5 website) that appear stacked up due to user permissions? Here is an example of the issue: <li class="divider"></li> <li>@Html.RouteLink("option1", "Route1") ...

Various placements in Internet Explorer, Chrome, and Mozilla Firefox

Currently, I am working on a website project The layout appears to be fine in Internet Explorer and Firefox, but there seems to be an issue in Chrome. Due to the length of the code, it cannot be posted here, so I have included links to the files: HTML: ...

Strange CSS problem occurring specifically on Firefox and Opera browsers

I have set up sharing buttons on my website, but they appear distorted on Firefox and Opera browsers. Interestingly, they render perfectly on Chrome and even Internet Explorer. Here is a preview of how it currently looks: If you are using Firefox or Opera ...

How to use Jquery to dynamically alter cell backgrounds in a table based on their values?

I successfully imported the table from MySQL to HTML, as shown below: https://i.sstatic.net/kzJtF.png My script is designed to highlight the two lowest and two highest values in each column: $(document).ready(function(){ var $table = $("#tbTodos"); ...

Retrieve JSON information utilizing a specific value stored in the localStorage

After an extensive search online yielded no results, I decided to seek assistance here. This is what I have managed to gather so far: JSON I possess a JSON file containing various lists of words that require retrieval based on user input. The structure ...

Issue encountered at 'site construction' phase: failure in build script with exit code 2

I am a novice and struggling to solve this error. I have attempted to fix it by adjusting the deploy settings, but I can't seem to resolve this compilation error. The syntax errors are overwhelming, and I'm not sure if there is something crucial ...

An overview on adding a new element to an array of objects in AngularJS

I have a feature on my website where users can create via points. Each user starts with one point, and if they want to add more, they can click "add" to insert a new object in the array with an empty value. The user then has the option to input a new value ...

Explore a JSON structure by clicking on a link using AngularJS

I am looking to develop a library in AngularJS that includes dropdown menus for selecting a book and then choosing a chapter from that book. Once a chapter is selected, the corresponding text should be displayed. All book data is available in a single JSON ...

Steps to modify the ShapeGeometry in three.js

As a beginner in three.js, I encountered an issue where updating a ShapeGeometry wasn't working as expected. This resulted in me having to remove and re-add the ShapeMesh every time. this.mesh.geometry.dispose() this.mesh.material.dispose() ...

Having trouble getting the submitHandler method in jQuery validation to work when submitting form data using $.ajax

When I use $.ajax to send data and validate with the jQuery validation plugin, the code looks like this: <div class="" id="ajax-form-msg1"></div> <form id="myform" action="load.php"> <input type="input" name="name" id="name" value ...

The quiet harmony of FeathersJS and Socket.io as they attentively listen to events is

I've been working hard to get everything set up and running smoothly, but it seems like I'm stuck on the last piece of the puzzle. Despite following the documentation closely, I can't seem to figure out what I'm missing. Here is the @an ...

Issue with Node.js and Express redirect not directing to intended URL

Utilizing the nodejs/express view engine in my application allows me to render an assigned template onto the screen when the route points to an existent URL. Previously, I had set up a redirect to the homepage for any user typing in an unexisting URL. Howe ...

Removing Borders from Dropdown Tabs in Bootstrap Navbar: A Step-by-Step Guide

I am facing an issue while using Bootstrap 4, as I am unable to remove the border that appears when selecting the drop-down tab. Here is a glimpse of the problem You can view the Inspector View here Check out the relevant code snippet ...

Implementing Hover Effect on Elements within Item template of GridView

I want to update the background color of GridView rows when the mouse hovers over them. It's working fine for columns within <boundfield>, but the background color of labels inside <itemtemplate> does not change on MouseHover. This is how ...

What is causing the border-radius property to malfunction on a particular website when using Internet Explorer?

We create browser add-ons for popular browsers like Google Chrome, Firefox, Safari, and Internet Explorer. Our add-ons inject HTML elements into various websites such as mail.google.com and email14.secureserver.net. The HTML element we use has a border-ra ...

The 'id' key is causing issues in React when used for mapping

While working on my simple messaging app, I encountered an issue where updating the same div with a new message was successful, but adding a new div for each message was not. Initially, I tried using index while mapping the messages to display, but it did ...

Utilize emit to distribute / allocate a variable

I have some variables stored in a file called server.js (and they tend to change frequently). My goal is to pass these variables to client.js whenever the client sends a request (triggers the 'validate' event). Even though the event is triggered, ...

Click a button to spin images around

Is there a way to rotate an image by 90 degrees, 180 degrees, and 360 degrees with the click of a button? <img class="test" id="image" src="images/image" alt="This is the Display Image" /> I attempted to use the following script, but was not satisf ...