Overflow and contain a flex item within another flex item

I am facing a challenge where I need to prevent a flex-child of another flex-child from overflowing the parent, ensuring it does not exceed the screen height or the height of the parent (which is also a flex-child).

Here's the CodePen link for reference.

I have attempted to replicate the HTML structure in line with the Vue project I am working on, and this represents the current layout I have.

Objective: The div element with class=card-body, containing multiple smaller v-card elements, is itself a child of a flex element. My goal is to ensure that it does not overflow the screen but instead gets an overflow setting. I haven't come across a solution that addresses this specifically. I prefer avoiding the use of calc as I want the flexbox to handle it dynamically, if possible.

Below is the outlined HTML structure:

<div id="app">
  <v-app id="inspire">
    <v-app-bar app dense color="primary">
      <v-toolbar-title class="white--text">
        App Title
      </v-toolbar-title>
    </v-app-bar>
    <v-content>
      <div class="d-flex flex-column full-height">
        <!-- TOOLBAR AND SHIZZ -->
        <v-row no-gutters class="flex-grow-0 flex-shrink-1">
          <v-col cols="12">
            <v-toolbar color="secondary" dense>
              <v-toolbar-title class="white--text">
                Some title
              </v-toolbar-title>
            </v-toolbar>
          </v-col>
        </v-row>

<!-- Content -->
          <v-card
    color="column"
    class="d-flex flex-column flex-grow-1 ma-4"
  >
    <v-card-title class="title-1">
      LMAO

      <v-spacer></v-spacer>
      <!-- Menu Component for column -->
      ICON
    </v-card-title>

    <div
      class="d-flex flex-wrap justify-center card-body ml-3 mr-1"
      :class="$vuetify.theme.dark ? 'card-body-dark' : 'card-body-light'"
    >
      <v-card
        v-for="item in 50"
        :key="item"
        class="mr-4 mb-3"
        :color="$vuetify.theme.dark ? 'card lighten-1' : ''"
      >
        <v-card-text class="title">
          Omae Wa Mou Shindeiru! Omae Wa Mou Shindeiru!
        </v-card-text>
      </v-card>
    </div>
  </v-card>

      </div>
    </v-content>
  </v-app>
</div>

The CSS styling used is as follows:

html,
body {
    overflow-y: auto;
    width: 100%;
    height: 100%;
}

.full-height: {
  height: 100% important;
}

.card-body {
  overflow-y: auto;
  max-height: 100%;
}

Answer №1

By some stroke of luck, I stumbled upon a simple solution that worked wonders without me fully grasping the mechanics behind it. To be honest, it was all trial and error.

All it took was using: flex-basis: 0

I've updated the CodePen for you to take a look

Check out the revised CSS below:

html,
body {
    overflow-y: auto;
    width: 100%;
    height: 100%;
}

.full-height {
  height: 100% !important;
}

.card-body {
  overflow-y: auto;
/*   max-height: 100%; */

/*   THIS IS THE KEY */
  flex-basis: 0;
}

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

Mark all checkboxes as checked automatically

Can anyone help me with my checkbox group issue? b-form-checkbox-group.ml-4.b-check( v-model="selected", v-if="productGroup.show", :options="productGroup.products", I want the list o ...

What is the process for customizing the image size of a WordPress RSS feed in pixels?

Is there a way to customize image sizes beyond the 'thumbnail', 'medium', and 'large' options? I tried setting width and height in the <img> tag within an RSS file, but it didn't work. Could it be a nested quotation ...

Enhanced JQuery Functionality with Additional Parameters

My current class setup is as follows: <div class="photo" parameter1="custom" parameter2="custom"></div> There are a total of 4 parameters in use. I am looking for a solution to pass these parameters within my photo div for JQuery coding, whi ...

Create a division that will remain visible on the screen and allow scrolling when a certain class is

Having some trouble with a fixed class div that is not continuing to scroll after the class is removed on scroll. I've attempted to fix this issue but the div keeps getting hidden instead of continuing to scroll. If anyone has any advice or can poin ...

Is there a way to display a message in a div container instead of using the alert box when there is a successful ajax response?

Hey there, I'm currently working on implementing error validation handling for a custom form that I've created. I'm looking to display the error messages in a designated div rather than using the standard browser alert box. Since I'm fa ...

Creating responsive CSS layouts for various device sizes

My webpage features a form with a prompt for the input box, followed by the input box itself. I want to implement two different layouts based on the device accessing the page. For cell phones, I want everything stacked vertically. However, for computers, ...

Toggle visibility of multiple DIVs with identical classes using radio buttons

I'm looking to streamline my use of radio buttons in HTML. How can I implement a single set of radio buttons at the top that will toggle the visibility of all DIVs with the same class on my webpage? <form> <input type="radio" name="csr_sel ...

Broken links detected in the Full Page Navigation menu on a one-page website

The hyperlinks on this particular page seem to be malfunctioning despite the fact that the li.a tags are correctly targeting specific section IDs. Markup: <header> <a href="#0" class="nav_icon"><i></i></a> </header> ...

Enhancing the appearance of text in an article by using hover effects, while ensuring the link is attached to the

As I work on the design of my website, I am faced with a challenge involving elements that have links attached to them. I want visitors to be able to click anywhere on the article and be directed to a specific page. The code snippet I currently have is as ...

What is the process for registering a click using a class in jQuery and retrieving the ID of the clicked element?

Currently, I am working on developing a webpage where I need to use jQuery to register a click using the items class and then extract the ID of that particular object. For example: HTML: <div class="exampleclass" id="exampleid1"></div> <d ...

What is the process for adding tailwind CSS via npm?

Before, I was including Tailwind using a CDN. Now, I have installed it with npm and all three .css files are included, but the styles are not appearing in my HTML document. Here is the directory structure and a link to style.css The content of tailwind.c ...

Removing scrollbar from table in React using Material UI

I successfully created a basic table using react and material UI by following the instructions found at: https://material-ui.com/components/tables/#table. The table is functioning properly, but I am finding the scrollbar to be a bit inconvenient. https:// ...

Differences between .php and .html: What causes variations in IE rendering?

After duplicating one of the HTML pages in my project, I simply changed the file extension from .html to .php. Surprisingly, all browsers display the page identically except for Internet Explorer (IE), which seems to handle the pages differently based on t ...

What could be causing the inability of Firefox4 to render the background color of the li element?

Is there a way to apply a background color to a forced inline element? I am having issues with displaying the background color in Firefox4, while it works fine in IE7. Can someone help me understand why this is happening and how to fix it? You can view th ...

Concealing the view-source feature in core PHP or HTML

Is there a way to conceal view-source in basic php or html? I've come across some information on this topic, but I'm having trouble grasping how to implement it: Web Developer Class: How to Hide your Source Code ...

Setting default values in Vuejs from browser URL parameters

I found a URL link that directs to different cities: Below is the Vue template code: <template> <ul> <li v-for="city in states" :key="city.id" :id="city.id" v-bi ...

My website, powered by Wordpress, is currently experiencing an issue with excessive whitespace being added to the bottom of the contact form 7 plugin. I am perplexed as to the cause of this issue and

Recently, I've come across an issue with my contact form 7 plugin, which has been integrated into the front-page.php file using the code below: <div id="contact" class="pad-section"> <div class="container"> <h1>Contact Us</ ...

Utilizing a custom filter for object manipulation within Vuetify's v-autocomplete

When using vuetify v-autocomplete with an object where the object consists of Key-Value pairs, the search functionality is based on the item-text. In my example, I am displaying the object as {1200-Chloride Systems}. Is it possible to make the search funct ...

Utilizing Vue.js to connect with a Node.js server

After setting up a basic Node.js server, the following code is running successfully: var http = require('http'); var server = http.createServer(); server.on('request', function(req, res) { res.writeHead(200, { 'content ...

The spacing in the Superfish menu is not aligned correctly

I am encountering a spacing issue with a superfish drop down menu. The problem can be observed here: To view the issue in action, visit this link: Essentially, all of the submenu items are floated left with a 50% width. I am looking for a solution to rem ...