Div flexes and compresses smaller than its content dimensions

Here's a link to the fiddle: check it out

Take a look at a normal card below:

https://i.sstatic.net/7Yqqv.png

But when the browser window is resized, it shrinks to this:

https://i.sstatic.net/1aexK.png

This is the HTML structure:

#product-list {
    overflow-y : scroll !important;
    height: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>

<body class="bg-faded h-100">

<!--This is where we insert the tabs-->
<div id="current-tab" style="" class="h-100 fixed-top">

<div class="container-fluid d-flex flex-row m-0 p-0 h-100 w-100">

   <div id="products"
         class="bg-white d-flex flex-column">

      <!--Product List-->
      <div id="product-list"
           class="card-deck p-4 bg-light">
          <!--Product card-->
          <div class="card mb-3">
              <img class="card-img-top"
                   src="https://cbp.s3.amazonaws.com/img/0/0/4/8/4/5/tn050016-the-national-trouble-will-find-me-2x12-vinyl-g-3.png"
                   alt="Card image cap">
              <div class="card-body">
                  <h4 class="card-title">Card title</h4>
                  <p class="card-text">Some quick example text to build on the card title and make up the bulk of
                      the card's content.</p>
              </div>

              <ul class="list-group list-group-flush">
                  <li class="list-group-item "><b class="pl-0 pr-5">Price</b>₱200.00</li>
                  <li class="list-group-item"><b class="pl-0 pr-3">Quantity</b> 19</li>
              </ul>
              <div class="card-footer d-flex border-top-0 pl-4 pr-4">
                  <a href="#"
                     id="edit-product-button"
                     class="btn btn-outline-primary ml-auto w-50 mr-3">Modify</a>
                  <a href="#"
                     id="delete-product-button"
                     class="btn btn-outline-danger mr-auto w-50">Delete</a>
              </div>
          </div>
      </div>
  </div>
</div>

The entire application has a position: fixed, but I needed #product-list to be scrollable so I added this CSS:

#product-list {
    overflow-y : scroll !important;
    height: 100%;
}

This project uses Bootstrap 4.0.0 beta and is optimized for Chrome.

Answer №1

Both #product-list and .card are styled with a display: flex; property. As .card is directly nested within #product-list and inherits the display: flex property, it will take up the available space—but only that much. Essentially, .card has a height of 100%.

To resolve this issue, follow these steps:

  1. Remove .card-deck from #product-list.
  2. Enclose all .card elements in a .card-deck wrapper.
  3. Change the height property of .card from height: 100%; to min-height: 100%;.

I have demonstrated these changes in this JSFiddle example, resulting in the desired behavior for .card.

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

Navigate to the specified text in the dropdown menu based on the ul li selection

Is it possible to achieve a functionality similar to that of a select box, where typing a keyword that matches an option in the select box will automatically move the pointer to that option? I am looking to implement a similar feature in my HTML code: < ...

Storing personalized HTML content in a database for individual users: A step-by-step guide

I have a JavaScript code snippet similar to this fiddle: http://jsfiddle.net/nj4N4/7/ On my webpage, it displays like this: image. When you click on the "add a year" button, a table resembling year2 appears above the previous year. Now, I'm looking ...

Footnotes integrated directly into the text using only HTML and CSS (in-line notations?)

Instead of appearing below or alongside the main content, notes on FiveThirtyEight expand within or below the paragraph when the note tag is clicked. They could be referred to as "in-notes" instead of footnotes. I personally find this system very efficien ...

Error occurs in Javascript when attempting to execute javascript code using PHP's echo and an unexpected identifier token is encountered

Currently, I am trying to insert a div into the page when a specific condition is met in PHP: if ($var == 0) { echo '<script>console.log("Test."); var res = document.getElementById("response"); res.innerHTML = "<div class='h ...

I can't find my unit test in the Test Explorer

I'm currently working on configuring a unit test in Typescript using tsUnit. To ensure that everything is set up correctly, I've created a simple test. However, whenever I try to run all tests in Test Explorer, no results are displayed! It appear ...

How can you utilize jQuery to eliminate specific select field values from the DOM prior to submission?

I am currently working on a Squarespace form that utilizes jQuery to show/hide specific fields in order to create a customized form using the show(); and hide(); functions. $(".option2 select").hide(); The issue I am facing is that simply hiding the fiel ...

The problem of Rails redirect_to not working with anchor and will_paginate gem

In my posts controller, I have implemented a feature where upon updating a post, it redirects to the specific post using an anchor tag. The challenge arises when dealing with pagination through the will_paginate gem. I have set up pagination to display fou ...

Using Android to Load HTML Content from a Database and Display in a WebView

I am currently facing an issue with loading HTML content from my sqlite database into a webview successfully. The HTML renders beautifully, however, the local file included in the HTML is not being loaded. I have placed it in the assets folder under this s ...

Showing pictures from a database utilizing PHP and HTML

I'm looking to showcase the images stored in my database within an HTML table. The files are saved as 'BLOB' and I want them to appear under the 'Photo' column. Can anyone guide me on the code needed to display these images? ...

Having trouble making elements in Tailwind CSS take up the entire page? Seems like they're getting stuck in smaller containers instead

I've been working on creating a layout for my webpage that is similar to the one found here: However, despite using Tailwind CSS, I'm having trouble with the flex styling and getting it to display correctly. import { ChevronRightIcon, HomeIc ...

Updating an iframe's content URL

I am currently working on building a website using Google Web Design and everything is going well so far. I have added an iFrame to the site and now I am trying to figure out how to change its source when a button is pressed. Most of the information I fo ...

Any tips on creating a website with a gradient background that moves along with the window as you scroll?

Can anyone help me figure out how to achieve this? I'm trying to create a similar effect to the one on the fireship website, but I'm having trouble replicating it. Appreciate any guidance. Thanks! ...

Instructions for including a scroll bar in an HTML side menu

Can anyone help me figure out how to add a scroll bar specifically for the left side navigation menu? I've tried adding overflow-y: scroll; in different places, but it hasn't worked so far. I'm still learning web design and have been piecing ...

HTML and JavaScript code to desaturate or grayscale image rollovers without the need for additional image duplicates or sprites

Is there a way to achieve grayscale to color image rollover effects without duplicating images or using sprites? I'm looking for an alternative technique that can accomplish this. Any suggestions on how to implement it? ...

Client request: receive a daily update detailing the differences between two databases

Today, a customer requested that I provide daily reports on the changes between two tables in our database. I am currently contemplating the most efficient and intelligent way to fulfill this request. Should I create a SQL procedure? Or perhaps an HTML p ...

What is the process for loading a PHP page dynamically within the <DIV> of another PHP page?

At this moment, I have two PHP pages named test1.php and test2.php. In the test1.php page, there are 2 DIVs: one labeled "SubmitDiv" and the other "DisplayDiv". Inside the SubmitDiv resides a Submit button. The desired functionality is that when a user cli ...

Utilizing Django to recycle an HTML block for multiple for loops within the same template

I have three specific states for an object - 1. to start, 2. started, and 3. finished. Upon filtering the objects in view, I pass three variables to the template - tostart_objects, started_objects, and finished_objects. My current approach involves loop ...

children in CSS grid expanding beyond grid boundaries

I am facing a challenge with my grid layout where the children's content needs to be scrollable. The grid is sandwiched between a header and footer, as illustrated below: <div class="app"> <div class="header"> Header </div> ...

Sending numerous HTML forms using a sole submit button through AJAX

On my website, I have a page named publish.php where users can input details for each image they upload. Each image has its own form, but only one form is displayed at a time in a tabbed layout when the user clicks on the corresponding thumbnail. I want to ...

Creating a stylish gradient text color with Material-UI's <Typography /> component

Is there a way to apply a gradient font color to a <Typography /> component? I've attempted the following: const CustomColor = withStyles({ root: { fontColor: "-webkit-linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)", }, })(T ...