Setting the Minimum Height and Enabling Scrolling for Divs

Just wondering if this is achievable, so I thought I'd inquire.

I've got a div layout with two columns inside a container. They're aligned using inline-block and percentage widths.

The basic structure looks like this

<div id="containter" style="width:100%">

<div id="leftDiv" style="width:20%; height:100%; display:inline-block; overflow-y:scroll">
     List of Content
</div>

<div id="rightDiv" style="width:80%; height:100%; display:inline-block; min-height:500px; vertical-align:top">
     Some expanding information
</div>

</div>

This setup is working fine. However, my issue lies in the fact that the left column has an overflow while the right column has a minimum height set. The goal is for the list in the left column to never exceed the containing div's height but rather fit into it at 100% and scroll when needed.

On the other hand, I want the content in the right column to be able to expand the height of the container as it grows, maintaining a minimum height of 500px and allowing the left column to grow along with it.

Currently planning to implement a JavaScript solution, but curious if achieving this purely through CSS is possible. Maybe there are some new features in CSS3/HTML5 that could assist?

Appreciate any insights you have on this matter.

Answer №1

The CSS property display:table; does not achieve the desired effect of making the left column scroll while keeping the document length constant. You can see an example of this issue in action in this fiddle.

To make overflow:scroll work as intended, you need to specify a height; for instance, setting max-height:500px; will produce the desired scrolling effect (example here). Trying to set the height to 100% may result in unexpected layout issues.

It seems that using JavaScript to handle both the layout and scrolling is the most effective solution in this case.

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 an image using parallax effect in jQuery

I have encountered a parallax effect issue while working on this site with pictures. The problem is that the pictures are getting clipped, and I need to figure out how to fix this issue. When I scroll down to a certain length, it cuts off the pictures and ...

I need to create a function that loops through each item in an array and repeats the process for each one

My goal is to create a button for each item in my array fetched from the database. Currently, only the first button functions correctly while the rest do not respond at all. Despite various attempts, I have been unable to resolve this issue. If more code ...

Is it possible to align Bootstrap buttons and input fields in a single row, and have the input field stretch to

I'm struggling to align Bootstrap buttons and input on the same line, with the input stretching horizontally while snugly fitting against the buttons. Here are my different attempts: https://i.sstatic.net/wuUsr.png In attempt #1: the button group an ...

The calculator is not simply adding two numbers; instead, it is combining them together to display something like "2+2=22"

<title>Calculator</title> <script type="text/javascript"> function Calculate(){ var myWorker = document.getElementById('myOperation'); var numberOne= document.getElementById('firstNumber').value; ...

Tips for making an interactive slider using JQuery

I need to create dynamic sliders within tabs that can change content dynamically. My development platform is ASP.NET MVC 5 and I'm using JSON data format. What's the best way to implement this dynamic slider feature for each tab? <div class ...

How can one element be made to rely on the presence of another element?

I'm currently working on my portfolio website and encountering an issue. Whenever I hover over an image of a project, the image expands in size, becomes less transparent, and a description of the project pops up. However, I would like to include a lin ...

What is the best way to transfer user authentication data from Django to a React application?

Currently working on a project that utilizes both django for front and back-end. While I've integrated a react page into the project, I'm facing a challenge in passing user information from django to the react page. The structure of my django set ...

What is the reason that filter_input does not work for retrieving form data when $_GET functions without any issues?

Currently, I am utilizing the get method along with a form to save the status of checkboxes into an array. I have made an effort to utilize a filter_input line to grab details from each checkbox one by one and store it in an array. Everything seems to wor ...

Shorten certain text in Vuetify

Here's an example of a basic select component in Vuetify: <v-select :items="selectablePlaces" :label="$t('placeLabel')" v-model="placeId" required ></v-select> I'm looking to apply a specific style to all selec ...

Update to CSS Height following a page resize

I'm in the process of developing an application with a left-hand side menu. The menu currently has the following CSS styling: .menu .levelHolderClass { position: absolute; overflow: hidden; top: 0; background: #336ca6; width: auto ...

What is the best way to make two divs appear side by side without causing the content below to shift as well?

I am trying to figure out how to position the Creams element underneath the "Name" section in my HTML setup. I have the following code: <h4 class="wrap-title">Name</h4> <button class="btn btn-primary btn-xs title-button" ...

Toggle the visibility of a Div element using PHP and jQuery

I am attempting to create 3 buttons that, when clicked, display the content of a PHP file. Here is what I have done so far: In the main HTML file: <div class="buttons"> <a class="showSingle" target="1">Logg</a> <a class="showSingle ...

React's Material-UI AppBar is failing to register click events

I'm experimenting with React, incorporating the AppBar and Drawer components from v0 Material-UI as functional components. I've defined the handleDrawerClick function within the class and passed it as a prop to be used as a click event in the fun ...

Add a Variety of Data Entries to a Table

I am currently attempting to add multiple pieces of data (from a date form) into a table using Jquery and MomentJS. However, the output does not appear as desired. Below is my code: $(".btnNext").on('click', function(e) { var Day = 1; ...

Ways to conceal specific content within a text using CSS

Help me with the updated code <html> <title>css</title> <head> <style> #st { z-index: -114; margin-right: -80px; } </style> </head> State Code : <span><span id="st"></span>Maharashtra - MH ...

The Nivo Slider is stealthily concealing my CSS Menu

Although this question has been previously asked, I am still unable to make it work with the solutions provided; The website in question is I have tried changing the z-index on all menu items to 99999, but they are still appearing below. <div id="sli ...

Using AJAX to submit a form and retrieve response data in Javascript

After successfully getting everything to post correctly, I encountered a problem with this script. It keeps loading the content into a new page. Could it be related to the way my php file returns it using "echo(json_encode($return_receipt));"? <s ...

Divide the text into uniform segments immediately following "/>"

I am currently faced with the challenge of breaking down an HTML file into chunks of a maximum size of 5000 bytes in order to accommodate AWS translate. Based on the assumption that a character can be at most 78 bytes in size, I have developed a simple fu ...

You are only able to click the button once per day

I am working on a button that contains numeric values and updates a total number displayed on the page when clicked. I would like this button to only be clickable once per day, so that users cannot click it multiple times within a 24 hour period. Below i ...

Positioning a flex item to the right by using float

I am in need of assistance with my HTML layout. <div class="container"> <div class="sidebar" style="float:right"> Ignore sidebar? </div> <div> main content </div> </div> The container is set to have a flex disp ...