What can be done to address the narrowing of the left div element as the right div's child elements grow in size?

Utilizing the power of flexbox, I have organized the UI into left and right panels. The child elements within the right panel are stacked vertically by utilizing the white-space: nowrap; CSS property.

However, there seems to be an issue where increasing the width of the right panel's child elements ("comps") causes the left panel to shrink instead of displaying a vertical scroll bar in the right panel. How can I rectify this situation?

(I have added two buttons for increasing the child element width and resetting it) https://i.sstatic.net/t2BBL.png Check out the code pen snippet

$(function(){

      $('#inc-width').click(function(){

        $('#inner-div').width($('#inner-div').width() * 2);
      });

      $('#reset-width').click(function () {

        $('#inner-div').width(1000);
      })
    })
.parent {
  display: flex;
  flex-direction: row;
}

.left {
  width: 20em;
  height: 40em;
  border: 1px solid;
}

.right {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.inner-wrap {
  white-space: nowrap;
  padding: 10px 0;
  background: green;
  width: 100%;
  flex: 1;
  height: 100%;
  overflow: auto;
}

.inner {
  display: inline-block;
  width: 1000px;
  height: 250px;
  background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
    <button id="inc-width">Increase child element width</button>
    <button id="reset-width">RESET child element width</button>
  </div>

<div class="parent">

    <div class="left">
      LEFT PANEL
    </div>

    <div class="right">

      <div style="flex: 1;">
        <div class="inner-wrap">
          <div class="inner" id="inner-div"></div>
          <!-- <div class="inner"></div>
          <div class="inner"></div> -->
        </div>

      </div>

    </div>

  </div>

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

The chosen choice is not able to be shown within the option tag

When attempting to filter options using JavaScript based on a selected item, I'm encountering issues. If the selected element contains 'CONTINUE' or 'BRACKET', it should be split into an array by space and only the first two indice ...

The search functionality in an Html table is currently malfunctioning

Currently, I am working on developing a search mechanism in HTML. It seems to be functioning properly when searching for data for the first time. However, subsequent searches do not yield the expected results. Additionally, when trying to search with empty ...

Arrange the selection options by price using jQuery

Sorting options by price is my goal, but despite trying various codes, I have not been successful! This is the original structure: <select id="product-list"> <option>product 1- [2$]</option> <option>product 2- [4$]< ...

Divs that are 30% of their parent's width will not align vertically and will not fit in a parent div that is 100% width

I am attempting to vertically center the three child-divs <div class="section"> as 3 rows in one column within <div class="container_page_2">. When I refer to vertical alignment, I mean having an equal distance between the top of the page and ...

Problem with JQuery binding

Currently, I have set up my radio buttons with jQuery bind using the code below: jQuery().ready(function() { jQuery("input[name='rank_number']:radio").bind('change', function(){ submitSelectedRank(); }); }); While th ...

Information arranged in a matrix

Hey everyone, I have all these input boxes and I want to organize them in a 3x4 or 4x3 grid layout instead of having them stacked on top of each other. I've tried using grid and other code but it just doesn't seem to work. Do you have any suggest ...

Error: Trying to access a property that is not defined (reference to 'user')

import { createSlice } from '@reduxjs/toolkit'; export const userSlice = createSlice({ name: 'user', initialState: { user: null, }, // The `reducers` field allows us to define reducers and generate associated actions redu ...

Ensure that the responsive SVG image remains centered even when resizing

I have been attempting to center crop the responsive SVG image while resizing. Even though I used preserveAspectRatio="xMidYMax slice", the image width does not stay consistent with my screen size. body{ margin:0;padding:0; } .wrapper { position: re ...

Restrict the HTML date input to only allow selection of the current date

In my form, I have set an input type date that is restricted to today's date by using the min and max attributes with JavaScript. The issue is that users are still able to manually input a different date instead of selecting it from the calendar popup ...

Why is my grid not showing the elements properly in ReactJS and CSS?

Currently, I am working with ReactJS, GridCSS in the Gatsby framework. I am attempting to create a subgrid within a subcomponent of the Gatsby layout.js file. However, after setting up my grid, the subcomponent fails to display the component correctly in i ...

A technique for horizontally centering an image while simultaneously ensuring that the bottom is pushed down, even at an unknown resolution, and maintaining center alignment if

Imagine a scenario where I have an image with unknown resolution. My goal is to horizontally center it, even if the window's width is smaller than the picture, while also adjusting the bottom of the window to match the height of this picture. Is ther ...

Disable the "top" property for the Material UI Drawer component

I'm currently working on implementing a Persist Left Drawer from Material UI that slides in from the left side. However, I don't want the drawer to cover the entire left side of the page. Essentially, I want to remove the "top" style property men ...

Implement a ListView that expands and displays items when each spinner item is clicked

As a novice in the realm of android development, I have encountered numerous challenges while attempting to integrate a List View within Spinner Items. Every time I make an attempt, it either displays errors or exhibits all the list view (array items) simu ...

In Angular 4, when choosing an option, only the Display Id is shown, not the Name

I'm currently working with Angular 4 Web API to display packingtypename when an option is selected. Everything is working fine, but I am facing an issue where only the packingtypeID is saved when clicking the add button. I would like to save both the ...

Button with opaque background over a see-through backdrop

I am having trouble making the button within a semi-transparent caption area over an image non-transparent. Any suggestions on how to achieve this? <div class="col-md-12 landing-container"> <img src="images/pig.jpg" class="main-imag ...

The spacing problem arises from the interaction between two HTML tags containing a Bootstrap file

view image details hereUsing Bootstrap 5, I have a screenshot with an h5 element in a black border and an em tag in a red border. I specified margin 0 to the h5 element but it still does not touch the em tag (in red border). I have tried adjusting line spa ...

Purge the external CSS files

Scenario In my React Router setup, most pages include their own .css files along with the default antd (UI framework) stylesheet: import '../styles.css'; This ensures that all components inherit these styles automatically. Issue at Hand Now, I ...

Rails: Generating HTML output straight from the controller

Looking for some guidance on handling the response from an AJAX call. Here's what I'm trying to achieve: Initiate an AJAX call to my Rails application to retrieve an HTML document. In the Rails controller, access the HTML document stored on dis ...

What is causing the position-sticky feature in Bootstrap 5 to not function properly?

My attempt at creating responsive card ads with Bootstrap 5 has hit a snag. The sticky-top feature doesn't seem to work properly on the left card. Specifically, I'm aiming to have a sticky sidebar on the left, containing a menu within a grid col ...

What could be the reason my HTML page is not properly rendering with my CSS file?

My stylesheet doesn't seem to be applying properly. Initially, I had all my CSS in the same HTML file. Then I created a separate CSS file and copied all my styles onto that file, but now the styles are not being applied. I have already checked for sy ...