Expanding one column in a full-screen, two-column layout

I have encountered a challenge while trying to design a layout with two columns that need to occupy the remaining height of their parent container. However, I want one of the columns to be able to extend beyond these bounds if its content requires it (in my case, an image).

To better illustrate what I'm aiming for, here is an image depicting the desired outcome.

https://i.sstatic.net/veypK.png

Important: The red border in the image represents the screen dimensions (100vw x 100vh).

This is what I have attempted so far:

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top {
  background: orchid;
}

.columns {
  flex: 1;
  display: flex;
}

.columns>* {
  flex: 1;
}

.left {
  background: lightgreen;
  /* Increase size to exceed 100% */
  height: calc(100% + 25px);
}

.right {
  background: cornflowerblue;
}
<div class="container">
  <div class="top">
    Top Content
  </div>
  <div class="columns">
    <div class="left">
      Left Column
    </div>
    <div class="right">
      Right Column
    </div>
  </div>
</div>

<div class="additional">
  Additional Content
</div>

The issue I am facing is that the "additional content" section is not being pushed correctly. This is because the left column overflows but does not technically impact its parent container. It seems like there are conflicting conditions at play and I am unsure how to resolve this. Any suggestions would be greatly appreciated.

Answer №1

If you're unsure if this solution is what you need, feel free to test it out and provide me with your feedback.

.box {
  display: flex;
  flex-direction: column;
  height:max-content;
}

.top-section {
  background: orchid;
}

.inner-columns {
  flex: 1;
  display: flex;
}

.inner-columns>* {
  flex: 1;
}

.left-side {
  background: lightgreen;
  /* Ensure a size larger than 100% */
  height: fit-content;
}

.right-side {
  background: cornflowerblue;
  max-height: 100vh;
}

Initially, the box is defined as max-content, indicating that its height adjusts based on the tallest element within it. Subsequently, the right side column uses max-height:100vh, which means that if the left side column does not reach 100vh in height, the container's height will be influenced by the right column. If the left column surpasses the threshold of 100vh set by the right column, the height:fit-content attribute of the left column triggers the parent container to expand, accommodating the additional content while keeping the right column at a fixed 100vh.

In such scenarios where the left column lacks adequate content, it may shrink smaller than the right column. Should this not align with your preferences, adjust the height of the left column accordingly, ensuring to utilize height attributes impacted by content (or min/max).

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

Is there a way to mix up the sequence of information when replying?

There have been numerous instances where this question has been raised and addressed, such as here, here, and here. However, those discussions pertained to Bootstrap 4, which is approaching its End of Life as of today, 2021-10-20. Given that Bootstrap 5 i ...

Achieving a Unique CSS Effect: Placing an Image on Top of a Card That Extends Beyond its Borders

As a newcomer to CSS, I’m not entirely sure what to call this effect or how to achieve it. Essentially, I am looking to create something similar to (picture 1), but all I have managed so far is (picture 2): https://i.sstatic.net/FrR16.png I’ve experime ...

Tips for integrating a unique font into your PhoneGap project

I've been attempting to incorporate a custom font into my PhoneGap application, trying out two different methods I came across online. Unfortunately, neither of them seem to be effective when using PhoneGap 3 and Xcode 5. First method involves using ...

Utilizing Node-Red: Linking an External CSS File with HTML Elements

If there are any resources on this particular topic available on the Node-Red website, please share them with me. My current project involves building a static website using HTML, JavaScript, and CSS with Node-Red. I am utilizing HTTP GET nodes to call my ...

What is the best way to align a single row in the center and another row at the bottom using Bootstrap?

I'm struggling with aligning two rows within a section element that has a vh-100 height. The first row consists of 2 cols (headers, image, and dropdown) that I want to vertically align to the middle of the container. The second row just contains an i ...

I am looking to implement user authentication using firebase, however, the sign-in page is currently allowing invalid inputs

<script> function save_user() { const uid = document.getElementById('user_id'); const userpwd = document.getElementById('user_pwd'); const btnregister=document.getElementById('btn-acti ...

Vertically centering elements within columns using CSS Grid

I attempted to bring a unique design to life using CSS Grid. While initially exploring Isotope JS for the same layout, I encountered some difficulties. Eventually, I was able to achieve a close representation of the design through CSS grid. There are a to ...

What's causing the appearance of a horizontal scrollbar?

I'm puzzled by the appearance of a horizontal scroll bar on my webpage and I can't seem to pinpoint the exact cause. I've tried simplifying the page as much as possible, but there still seems to be an issue. Here's all the information I ...

Text field imposter - How to move icon to the right when focused

http://jsfiddle.net/g54p4/ If you need to view the HTML and CSS, it's available on jsfiddle. <div class="box-input"> <input type="text" placeholder="Email Address" class="input-icon-email cly-pvxl" name="email"> </div> ...

Get a polished look using HTML and CSS exclusively

Allow me to illustrate what I am intending to accomplish with an example. div{ width:100px;height:100px; border:3px solid #900; border-radius:0px 0px 140px 0px; } <div></div> I am seeking a method to ...

it will still function properly regardless of the width being set to zero

Is anyone able to explain the strange phenomenon I am experiencing with this code snippet? In this particular example, I have set the width of selector h3 to 0. However, when viewing it in IE 9 using F12 development tools, I can see that the width is indee ...

Identifying a span element and appending to its classList

I am currently working on code that generates spans, and my objective is to adjust the color of specific spans based on their text content. I have identified a section where I need assistance with the syntax of the code I should input. My aim is to locate ...

How to create vertical spacing between <a> elements within the same div using HTML and CSS

Currently, the layout in picture 1 shows how my content is displayed. I am looking to create spacing (bottom margin?) between the images like the example in picture 2. The two side-by-side blocks are separate DIVs, and the images within each line belong to ...

Manipulating CSS for a certain ID that is applied to multiple elements with the help of JQuery

I am attempting to conceal all div elements except the initial one within a specific ID. Despite my efforts to create a custom jQuery script, it does not appear to be functioning. $("div.hero-featureSwap:not(:first)").css({display:none}); Is this scr ...

Creating identical class names for UL elements underneath LI using JavaScript

In my attempt to dynamically generate the class name within the ul element, I successfully achieved the expected result. The outcome can be viewed in the console of the snippet provided for reference. However, I'm facing a challenge when attempting t ...

Tips for placing a background color *behind* a bootstrap button

When a button is clicked, I want to display an input with a background surrounding both the button and the input. Currently, my markup renders like this: https://i.sstatic.net/rxaPt.png So when the button is clicked, I need a yellow (alert-warning) backg ...

Troubleshooting problem with CSS scaling on smartphones

I'm attempting to create a website (the first one I've ever designed) dedicated to my girlfriend's cat. However, when viewed on a mobile device, it doesn't look good. I've made an effort to adjust the meta viewport tag, but it does ...

Creating interactive dialogue: the speech bubble script

I'm having trouble with my code overlapping in sections, and I just can't seem to figure out why. I've tried adjusting borders, adding padding, adjusting spaces, changing widths, reviewing the code, and even removing absolute positions, but ...

What are some creative ways to customize v-slot:cell templates?

Currently, I have the following code snippet within a table: <template v-slot:cell(checkbox)="row" style="border-left='5px dotted blue'"> <input type="checkbox" v-model="row.rowSelected" @input="toggleS ...

Assistance needed for Internet Explorer

When I designed a webpage in Firefox, everything looked great. However, when I opened it in Internet Explorer and resized the window to less than maximum size, half of the main div disappeared under the footer. If you want to see the issue for yourself, v ...