Is the height of each column the same as the deepest column?

If my div layout looks like this:

<div id="stretchyheader"></div>
<div id="fixedwidthwide"><div>
<div id="fixednarrow></div>
<div id="footer"></div>

Resulting in the following structure:

-----------------------------------------------------
|          stretchyheader                           |
-----------------------------------------------------
      |                     |              | 
      |                     |              | 
      |    fixedwidthwide   |  fixednarrow |
      |                     |              | 
      |                     |              | 
      |                     | --------------
      |                     |             
      |                     |             
      |                     |       patterned          
      |                     |       background
      -----------------------
                    -  footer  -

Is there a way to make sure that both columns have the same height as the tallest column? The heights of the columns are adjustable based on the content and have a white background.

Answer №1

If you're looking for a straightforward method, consider implementing Faux Columns to achieve the desired effect.

Your HTML structure could resemble something like the following:

<div id="stretchyheader"></div>
<div id="container">
    <div id="fixedwidthwide"></div>
    <div id="fixednarrow></div>
</div>
<div id="footer"></div>

To visually enhance both columns, apply a background image to #container where you can include colors, borders, etc.

While there are more complex CSS methods available, such as:

Answer №2

Extracted from this source:

To ensure equal height columns, place the two fixed columns within a container and apply CSS as shown below:

#container {
    float:left;
    width:[total width of both columns];
}
#fixedwidthwide {
    float:left;
    width:[specific width];
}
#fixednarrow {
    float:left;
    width:[specific width];
}

Please note that this method is only necessary if uniform column heights are required. Otherwise, consider using faux columns as recommended by philfreo.

Answer №3

There are various solutions available to tackle this issue, such as the OneTrueLayout Technique, the Faux Columns Technique, and the CSS Tabular Display Technique.

The most effective approach for creating columns of equal height is the CSS Tabular Display Technique, which involves leveraging the display: table property. This technique is compatible with Firefox 2+, Safari 3+, Opera 9+, and IE8.

The implementation code for the CSS Tabular Display:

The HTML

<div id="container">
    <div id="rowWraper" class="row">
            <div id="col1" class="col">
                Column 1<br />Lorem ipsum<br />ipsum lorem
            </div>
            <div id="col2" class="col">
                Column 2<br />Eco cologna duo est!
            </div>
            <div id="col3" class="col">
                Column 3
            </div>
        </div>
</div>

The CSS

<style>
#container{
    display:table;  
    background-color:#CCC;
    margin:0 auto;
}

.row{
    display:table-row;
}

.col{
    display: table-cell;
}

#col1{
    background-color:#0CC;
    width:200px;
}

#col2{
    background-color:#9F9;
    width:300px;
}

#col3{
    background-color:#699;
    width:200px;
}
</style>

In scenarios where the table-cell width expands automatically causing issues, a simple solution is to add another div within the table-cell with a fixed width. However, over-expanding may occur in rare cases like exceptionally long words or wider divs than the table-cell's width.

The Faux Column Technique may offer a workaround, but it requires resizing the background image for column adjustments and lacks elegance.

The OneTrueLayout Technique involves creating an extensive padding-bottom to simulate equal heights, then adjusting the border position with negative margins. An example:

The HTML file:

<html><head>
<style>
.wraper{
    background-color:#CCC;
    overflow:hidden;
}

.floatLeft{
    float:left; 
}

.block{
    padding-bottom:30000px;
    margin-bottom:-30000px;
    width:100px;
    background-color:#06F;
    border:#000 1px solid;
}
</style>
</head>
<body>
    <div class="wraper">
    <div class="block floatLeft">first col</div>
        <div class="block floatLeft">
                Second col<br />Break Line
        </div>
    <div class="block floatLeft">Third col</div>
</div>
</body>
</html>

An unimplemented aspect I find unfavorable is the inability to achieve 100% height within a container of automated height, prompting the need for revision by W3C.

Additional resources: link1, link2, link3, link4, link5 (important)

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

Tips on ensuring CSS is properly loaded on a Django HTML page

Despite numerous attempts, I cannot get my CSS to render properly on any of the HTML pages within a Django project. I've tried various solutions from Stack Overflow, such as adding the following code snippet: <link rel="stylesheet" href=& ...

Enhancing div elements with Bootstrap 3 scroll effects

I have a web design project that involves using Bootstrap 3, and I need guidance on how to achieve a specific layout in the correct way: The layout in question consists of two divs that cover 100% of the screen at any given time. The first div needs to re ...

Tips for resizing the MUI-card on a smaller screen

Is there a way to adjust the width of the card on small screen sizes? It appears too small. You can view my recreation on codesandbox here: https://codesandbox.io/s/nameless-darkness-d8tsq9?file=/demo.js The width seems inadequate for this particular scr ...

What is the best way to create a transparent effect over a solid color using CSS in the following situation?

I have been using the spinner on this website "". Specifically, I am referring to the third one in the first row. When I apply it to my system, a solid color appears in the center of the circle. However, I want to make it transparent, but when I attempt ...

Learn how to use Bootstrap to style your buttons with centered alignment and add a margin in between each one

Looking to center four buttons with equal spacing between them? Here's what you can do: |--button--button--button--button--| Struggling with manual margin adjustment causing buttons to overlap? Check out this code snippet: <div id=""> ...

Difficulty with Jquery's random selection of grid divs

I am working on a grid layout consisting of 9 divs nested in columns of three. The objective is that when the main grid (with ID #left) is clicked, two divs from the middle row (row="1") should have the class .show randomly applied to them. In the column w ...

IE encounters an absolute z-index problem when expanding concealed content

I'm having trouble with the positioning of a block (div). I am new to CSS, so any help would be greatly appreciated. Here is the code snippet: http://jsfiddle.net/9rEmt/ (please check it out) for viewing online in IE. When I use absolute for positio ...

Change the position of an HTML image when the window size is adjusted

My web page features a striking design with a white background and a tilted black line cutting across. The main attraction is an image of a red ball that I want to stay perfectly aligned with the line as the window is resized, just like in the provided gif ...

Questions regarding the navigation bar

I am currently working on designing a navigation bar featuring a dropdown menu. I envision HOME, FIXTURES, RESULTS, LEADERBOARD all appearing on the same line. Specifically, I would like UPCOMING WEEK, MONTHS to be the dropdown children of FIXTURES, and G ...

Updating the value of a localStorage key after each successful AJAX call in JavaScript

I'm currently facing a challenge with my local storage key value. The issue is that it doesn't update the value when the AJAX call successfully returns data. It only retains the old stored data, requiring me to manually refresh the page by pressi ...

Navigating to a different page in Ionic 2 when a link or button is clicked

When I click on the link provided below, it should take me to the home page. However, I am facing issues and it is not redirecting me as expected. I want to be taken to the home page when clicking on the specified link or button. Do I need to add any Ang ...

Arranging Elements Using CSS

Currently, I am working on aligning and positioning my items using CSS. However, I'm a bit confused about the right approach. Here is a demo of my current progress: Demo Link I aim to achieve a layout similar to this sketch: Sketch Image Apologies ...

Tips for Displaying JSON Data on an HTML Page

How can I display JSON data in an HTML web page and group names from the JSON Data only? Here is the URL for the data: http://www.celeritas-solutions.com/pah_brd_v1/productivo/getGroups.php?organizationCode=att&userId1 I have searched online and fo ...

What is the Best Way to Utilize CSS ID Selectors with Next JS?

After discovering that npx create-react-app is no longer supported, I decided to delve into Next JS as a new framework. My goal now is to transition one of my websites from pure HTML, SASS (CSS), and JavaScript to utilizing Next JS and SASS. The current c ...

CakePHP allows developers to easily include images in their links using the `$this->Html->link` method. However, instead of generating HTML code for the image, it outputs ASCII characters

I can't seem to find the solution in the CakePHP 2.3.0 manual. I am trying to use $this->Html->link with $this->Html->image to create a clickable image. However, I'm encountering an issue where the ASCII rendering of quotes is being g ...

CSS - using numbers to create dynamic background images

I am looking to create a design where the background images in CSS display increasing numbers per article, like this example: This idea is similar to another post on Stack Overflow discussing using text as background images for CSS. You can find it here: ...

optimal method of storing and retrieving an array in a database

I have a set of HTML inputs that can be regenerated using JavaScript to allow users to input their experience history. Let's assume this code is generated twice like the following: <!-- User Experience 1 --> <label>Company Name</label& ...

Submitting a form using jquery in HTML

Below is the code I have created. It consists of a text-input field and a 'Search' button within a form. Upon clicking the search button (submitting the form), it should trigger the .submit function to carry out the necessary processing. HTML CO ...

Position flex-box items to align with the baseline of the final line of text within a block

I am attempting to replicate the layout shown in the final example of the image linked below using flexbox. https://i.sstatic.net/KSaig.png It seems that the align-items: baseline; property works perfectly when the blocks contain only one line of text. ...

React - Obtain User Login Details and Verify

I am working on a React project that includes a Login Form. The code has been organized into small components for reusability, but I am unsure of how to retrieve and validate user credentials (username and password). Is there a method available to validate ...