Equalize the height of columns by making them all float at a uniform 100%

Let's discuss the challenge of having 3 floated columns.

Take a look at this example: http://jsfiddle.net/A9dqD/

html, body {height: 100%;}
#a {
    float: left;
    height: 100%;
    width: 50%;
    background-color: green;
}
#b {
    float: left;
    height: 100px;
    width: 50%;
    background-color: blue;
}
#c {
    float: left;
    height: 300px;
    width: 50%;
    background-color: red;
}

The goal is to make column A as tall as column C (to match backgrounds).

Currently, it appears that making column a take 100% of the screen height is a challenge. The body takes up 100% of the viewport height but not the entire document height, resulting in column a being only as tall as the viewport.

For a real-life example, check out:

Instead of using jQuery to manually set the height, I'm exploring simple CSS tricks to achieve this. Your input is greatly appreciated!

Thank you!

Answer №1

If you want #a to fill the entire height and #b to be a fixed 100px, try this solution for #c:

#c { height: calc(100% - 100px); }

Check out this jsFiddle example for a demonstration.

Note: Ensure you have a fallback height value in place for browsers that do not support the calc() function.

Answer №2

Instead of using pixels for col b, consider using percentages. Set col b to 20% and col c to 80%, ensuring they add up to 100% of col a. This way, col b doesn't have to be exactly 100px. You can also use the cal() function. Here is a page listing browsers that support it: http://caniuse.com/calc

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

Ensuring Bootstrap Cards (version 4.4.1) Blend Seamlessly with Body Text for a Cohes

https://i.sstatic.net/Dqywt.png I have implemented a card similar to the one displayed on my homepage, but I would like it to be aligned left and take up less horizontal space. Additionally, I want the text to wrap around the card rather than being comple ...

How can the background color of a DIV be altered based on the values of an array's minimum

Basically, I am fetching values from an array using AJAX. The background color will change from green to red based on the "aht_value". Currently, the colors are displaying correctly because I hardcoded the values in the calculation below. However, I want t ...

Center the span in CSS by setting its position to absolute

I am trying to create a span element positioned as absolute inside a div. The div has top and left values set. When the user inputs text, the span expands with the given text towards the right to contain it. However, I would like it to grow symmetrically o ...

Stopping the parent onclick event from propagating to a child element within a bootstrap modal

I am currently working with angularjs and bootstrap, incorporating nested onclick events using Angular's ng-click in various HTML elements. One is located in a table header to display different sort icons and execute the sorting logic when the header ...

Is it possible to integrate a PDF file into a webpage while also preventing users from downloading it?

I need help with a website that has various PDFs available for users to view. However, we want to prevent users from downloading these PDFs. Ideally, I'm looking for a solution using JavaScript/HTML. We've attempted different methods to disable ...

Creating a responsive loading button using Bootstrap 5

I'm struggling to create a button that displays a loading message. In my HTML file, I have: <div class="btn-area"> <button id="connectMetamaskBtn" class="btn sp-btn" type="button" ...

Having difficulty in setting a Cookie with php

Working on integrating social login, I attempted logging in with Facebook. Upon successful authentication of the user, I aim to retrieve their value and store their ID in a cookie to establish a session throughout the site. Below is the code snippet, < ...

Fixing the problem of horizontal labels in Bootstrap - a step-by-step guide

I am struggling to display the form label on a single line, as it currently appears on two lines. Any suggestions for showing the form label in a single line? https://i.sstatic.net/cXddd.png <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm ...

Row in Internet Explorer 7

I have a function that reveals hidden rows in a table, which works perfectly in all tested browsers except for IE7. The function is written using Prototype.js. function showInactives(){ var row_list = $$('tr.inactive'); var ck =$('inactive_ ...

Filter data using dropdown in PHP PDO

Is there a way to update the datatable based on filter criteria? I am using Drop Down Search with branch ID as BID, outlet ID as OID, and user ID as UID. Below is my code snippet where I encounter an issue mentioning 'draw' not defined along with ...

Setting div HTML as an attribute in jQuery

I am facing an issue with assigning a div content (barcode) from my database as an attribute to my select option. Whenever I assign it, the option ends up getting distorted. Can anyone provide some guidance on how I can achieve this successfully? I have al ...

Can you use both HTML and JSON in ROR?

The scaffolding process generates controllers that include Create/Update methods. These methods are responsible for rendering HTML as well as JSON data. While I am familiar with HTML, I have limited knowledge about JSON. Should JSON be included in this cod ...

Adjust text alignment based on the mobile device screen size using Bootstrap 4

On smaller devices, the layout of my horizontal label and text field is not as I expected. It appears like the image below: https://i.sstatic.net/9I8Os.png I am trying to make the First Name label left-aligned on small devices. Here is the code I have be ...

Challenges with fading images using jQuery

I am currently working on animating a 5 image slideshow by creating a fading effect between the images rather than just switching abruptly. Here is my HTML structure: <div id="slides"> <ul class="pics"> <li><img src="imag ...

Submitting the $_SESSION variable with HTML

Hi there, I hope everyone is doing well. I think I may have worded the title incorrectly, so I apologize for any confusion. Here is the code I'm working with: <form method="POST" action="checkoutManager.php" name="submitOrder"> <?php if(is ...

coding with javascript and css

Essentially, I am trying to add padding specifically to the left side of this code snippet: if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("live ...

Working with Thymeleaf and DatePicker to establish a minimum date

Looking to establish a minimum selectable date in my datepicker using Thymeleaf. Attempted code: <label th:utext="#{${name}}" th:for="${name}" class="control-label"></label> <div class="input-group input-group-prepend"> <span cla ...

How to create a Navbar with a fixed-top position and ensure the container beneath it stays fixed to its bottom even when scrolling

https://i.sstatic.net/EgrDC.jpgWhen using the "navbar fixed-top" feature from Bootstrap, I have noticed that the container underneath it tends to slide below the navbar when scrolling down the page (see attached photo). Although this is expected behavior w ...

Shutting down the Fancybox Window

Included in this code is a button that triggers the opening of a fancybox containing a form. Once the form is filled out and submitted, I want the window to close automatically and be replaced by another window displaying a success message. This success me ...

My website is optimized for desktop and tablet viewing, but unfortunately it is not responsive on mobile devices. Can you advise on how to fix

I recently completed a portfolio website using HTML, CSS, Bootstrap 4, and jQuery. While the site displays properly on the browser and up to tablet mode, I encountered issues when viewing it on my phone. There seems to be a blank area that can be scrolled ...