Adjustable width columns in Flexbox design

I need assistance with creating a responsive three-column grid layout using Flex in CSS. I have achieved a fairly responsive design by following the CSS provided in the fiddle link below. However, I am facing an issue where the second column (the blue one) is not shrinking when resizing the screen, causing the yellow column to disappear instead. Please refer to the example gif for clarification: Example video

How can I adjust the CSS to make the blue box shrink when resizing so that the yellow box remains visible?

This is the current CSS implementation:

.container-main {
    margin: 50px;   
}

.box-container {
  display:flex;
  //align-items: flex-start;
  background-color: #cccccc;

  align-content: stretch;  

}

.box-tick-code {
    background-color: red;
    flex-basis: 100%;
    height: 40px;
flex-flow: row nowrap;
    flex-shrink: 2;
    min-width: 0px;
    min-height: 0px;
    overflow: hidden;   
}

.box-tick-title {
    background-color:blue;
    display:flex;
    flex-basis: 100%;
    height: 40px;
    flex-shrink: 1;
    min-width: 0px;
    min-height: 0px;
    overflow: hidden;   

}

.long-title {
  overflow:hidden;
  display:inline-block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-more-info {
    background-color:yellow;
    flex-basis: 100%;
    height: 40px;
    flex-shrink: 2;
        min-width: 0px;
    min-height: 0px;
    overflow: hidden;
}

You can view the HTML/CSS code in this JSFiddle link:

Link to the HTML CSS in fiddle

Answer №1

To avoid issues, make sure that you include the view port meta tag in your HTML page or file. Here is the code to add to the head section:

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

If you do not specify a different value, there is no need to set (min-height) and (min-width) to (0).

Below are the snippets of CSS code that are functioning correctly:

 .container-main {
    margin: 50px;   
}

.box-container {
  display:flex;
  //align-items: flex-start;
  background-color: #cccccc;

  align-content: stretch;  
}

.box-tick-code {
    background-color: red;
    flex-basis: 100%;
    height: 40px;
flex-flow: row nowrap;
    flex-shrink: 2;
    overflow: hidden;   
}

.box-tick-title {
    background-color:blue;
    display:flex;
    flex-basis: 100%;
    height: 40px;
    flex-shrink: 1;
    min-width: 0px;
    min-height: 0px;
    overflow: hidden;   
}

.long-title {
  overflow:hidden;
  display:inline-block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-more-info {
    background-color:yellow;
    flex-basis: 100%;
    height: 40px;
    flex-shrink: 2;
    min-width: 0px;
    min-height: 0px;
    overflow: hidden;
}
<div class="container-main">
                <div class="box-container">
                  <div class="box-tick-code">
                    <div class="long-title">title</div>
                  </div>
                  <div class="box-tick-title">
                    <div class="long-title">imagine if there is some title here</div>
                  </div>
                  <div class="box-more-info">
                    <div class="long-title">title</div>
                  </div>
                </div>
              </div>

This response is based on the GIF example you provided.

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

What could be causing my resize event to not trigger?

My goal is for the #sequence div to be full height of the browser window when the window size is greater than 920px in height. In such cases, I also want to trigger a plugin. If the window size is lower than 920px, then the height of the #sequence div shou ...

Ensure that the assistant stays beneath the cursor while moving it

I am currently working on creating a functionality similar to the 'Sortable Widget', but due to some constraints, I cannot use the premade widget. Instead, I am trying to replicate its features using draggable and droppable elements: $(".Element ...

Aligning the last element within a list

I'm having a major issue with this code. Despite reading all related posts, I still can't get it to work. Seems like I might be missing something obvious. LOL. Here is the site (best viewed in Chrome): and here is what I believe is the simplifi ...

How can I effectively showcase the content of a text file in HTML using Flask/Python?

Let's discuss the process of displaying large text/log files in HTML. There are various methods available, but for scalability purposes, I propose taking a log file containing space-separated data and converting it into an HTML table format. Here is ...

What is the best way to format text within the _e() function in WordPress?

As I work on developing a basic plugin, I encountered the following line of code: echo "<p style=\"color:red;\">Please enter a valid email address!</p>"; I aim to make this plugin easy to localize and internationa ...

CSS Table Style Chaos

When styling a table using CSS, I encountered this line within the code: .pricing tr td:last-child { text-align: right; } This particular line ensures that the text in the last column of the table aligns to the right. The class "pricing" is applied to th ...

Tips for including a line within a circular canvas

My progress bar crafted with css, javascript and html looks great (left image). However, I'm facing a challenge in adding white color dividers to enhance the appearance of the progress bar as shown in the image on the right. Despite my various attemp ...

How to target the following element with CSS that has a specified class name

Would it be possible to achieve this using CSS alone, or would I need to resort to jQuery? This is how my code currently looks: <tr>...</tr> <tr>...</tr> <tr>...</tr> <tr class="some-class">...</tr> // My g ...

PHP is receiving data from $.post in an invalid format

I am facing a challenge in sending a JavaScript Object() to a PHP file in the correct format that $.POST requires. The PHP file does not establish any $_POST[] variables, which suggests that I may be transmitting the data in an improper format. JS: $(&ap ...

The -webkit-linear-gradient effect can lead to noticeable banding issues on Chrome and Safari browsers

The title pretty much sums it up. The first image below is a screenshot of a page that is about 8000 pixels tall, taken in the most recent version of Chrome: On the other hand, this image depicts a different page (with the same CSS), which is only about 8 ...

Is there a way to position the button at the bottom right corner of my div box?

Having trouble positioning the button in the bottom-right corner of the parent div? I attempted using float: right;, but it ended up outside of the box. How can I keep the button within the box and align it to the bottom-right corner? If you have a solutio ...

Preventing Event Propagation in Angular HTML

I am encountering an issue with stopPropagation, and I need assistance with implementing it in HTML and TypeScript for Angular. The problem is that the dialog opens but also triggers a propagation. Below is my code snippet in HTML: <label for="tab-two ...

Issue with the formatting of the disabled button

I am facing an issue with styling a disabled button. Whenever I try to apply custom styling, it reverts back to the default styling. I have already cleared my cache but the problem persists. The button is disabled using JavaScript with document.getElementB ...

When the button with an image is clicked, it will display a loading element

I have developed an application that heavily utilizes ajax, and I am looking to implement the following functionality: I would like to have a button with both text and an image. When this button is clicked, it should be disabled, and instead of the origina ...

Resizing and uploading multiple images with accompanying descriptions

I am in need of a solution for uploading multiple images along with descriptions. Users will be uploading 1-10 large-sized images from cameras, so it would be ideal if the images could be resized before the upload. My requirements are: Compatibility wit ...

Assign a unique identifier to the Angular mat-checkbox component

I need to attach an ID to an Angular material checkbox. I have an object called item. When I check the HTML code, it shows 'item.id + '-input'. However, when I bind the name, it works fine with just 'item.id'. Below is my current ...

Script to pop up cancel alert box

There's a dilemma with this code - if you click CANCEL the first time the box pops up, it continues to run. I'm unsure of how to make it redirect to the underlying page when clicked on cancel for the first time. var numero= prompt ("Enter a nu ...

Tips for Aligning Several Images Horizontally in an Article

Does anyone know how to center pictures in an article horizontally? I've tried various techniques without success. If it would be helpful, I can share the CSS I currently have. However, I am open to starting from scratch with the CSS as well since I ...

The Firefox browser is not rendering the website correctly

After successfully programming a website with the FullPage Slider from this source, everything was working fine except in Firefox. Specifically, one section containing a table with image overlay hover effects from these effects library was not functioning ...

Employing the html.validationmessagefor to display a client-side error notification

My text fields have server-side validation messages. The field 'title' is a required field on the server side with a '[Required]' data attribute in the class, but it only seems to be checked on a postback or form submit. I am saving the ...