"Utilize CSS Flexbox to create a layout with set width and uniform

Within a container, I have organized three sections. As I adjust the size of my browser to a maximum width of 668px, I want section 1 and section 3 to be displayed in one row while section 2 is placed below them. The width of section 2 should be proportional to the combined width of section 1 and section 3.

However, when I decrease the browser size to 668px and below, section 3 becomes invisible.

This is my attempted solution:

@media (max-width: 668px) {
  .container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-self: flex-start;
  }
  .container .section1 {
    height: 300px;
  }
  .container .section1,
  .container .section3 {
    flex: 0 0 262px;
    margin: 3px;
    display: block;
    flex-grow: 0;
    flex-shrink: 0;
  }
  .container .section2 {
    flex: 0 0 500px;
    flex-grow: 0;
    flex-shrink: 0;
    order: 1;
    min-height: 235px;
  }
}

@media (max-width: 940px) {
  .container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-self: flex-start;
  }
  .container .section1 {
    height: 300px;
  }
  .container .section1,
  .container .section3 {
    flex: 0 0 262px;
    margin: 3px;
    display: block;
    flex-grow: 0;
    flex-shrink: 0;
  }
  .container .section2 {
    flex: 0 0 500px;
    flex-grow: 0;
    flex-shrink: 0;
    order: 1;
    min-height: 235px;
  }
}
<div class="container">
  <div class="section1">Section 1</div>
  <div class="section2">Section 2</div>
  <div class="section3">Section 3</div>
</div>

Answer №1

Your CSS code is missing a specified height for .section3.

For .section1, the height is set to 300px.

For .section2, the minimum height is set to 235px.

Consider adjusting your code with the following:

.section1, .section3 {
    height: 300px;
}

Check out the jsFiddle demo here

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

Utilizing deployJava.runApplet for precise element targeting

After years of successfully maintaining an applet that utilizes the traditional: <script src="foo.js"></script> method for embedding a Java applet, we can no longer ignore the need for change. It's time to switch to: deployJava.runAppl ...

What is the procedure for extracting data from a JSON file within an HTML document?

Hey there, I am currently working on reading data from a json file using ajax. I have created a Video object that consists of Courses objects with titles and URLs. However, when attempting to read the title and URL of HTML as an example, I am not seeing a ...

Is there a way to expand the navbar to full width?

I am currently designing a layout that includes a side menu and a top navbar using Bootstrap 4. My goal is to have the side menu extend from top to bottom and the top navbar stretch from the side menu to the right edge of the screen. How can I achieve th ...

Setting custom domains on Heroku is essential for optimizing the performance and branding of my website

Essentially, when using Heroku, you are provided with a default domain: XXX.herokuapp.com. Personally, I have a collection of REST APIs that I want to configure on a domain called: api.myDomain.com. At the same time, I also have my HTML files (web view) ...

Ending a div tag inside another div element

I have set up a listings page with individual divs for each listing, loading content from a separate php script using $.post The issue I'm facing is hiding the listing, possibly related to this line of code: $('div.close_listing') I can o ...

The functionality of "Priority Nav" is compromised when a div is floated

I am currently utilizing the "Priority Navigation" design technique. This means that when the viewport width is reduced and there isn't enough space for all the list-items to fit horizontally, they are moved into another nested list under a "more" lin ...

Is there a way to do HTML select-option in a reversed order?

Having an issue with my HTML select element: <select> <option>...</option> <option>...</option> <option>...</option> </select> Currently, all the options are displayed below the select field. I ...

Issue with JQuery delay functionality not activating correctly upon clicking an <a> tag

When I click on an <a> tag, I want to display a div and wait for 10 seconds before redirecting. However, the div is currently being shown immediately without waiting. Here is the HTML code: <a class="clickHereToDisplay" href="http://www.google.c ...

Event handlers for textboxes in Visual Web Developer are a crucial component for

Having some difficulty with textboxes - ideally, I would like my second textbox to clear whenever the text in my first textbox changes. Currently, it only clears on postback but is there a way to achieve this without needing a postback for each character ...

Incorporating jQuery to Load Content into a DIV while preserving the original JavaScript

I am attempting to implement the following <script> $(document).ready( function() { var data = 'testing' $("#about").on("click", function() { $("#main-content").load("/about.html"); ...

Unable to decipher Material UI class names

I am experimenting with a React app using Material UI to explore different features. I'm attempting to customize the components following the original documentation, but making some changes as I am using classes instead of hooks. However, I keep encou ...

A comprehensive guide on how to find keywords within an array and then proceed to make all text within the parent div tag stand

I am currently looking for a webpage that displays a list of products based on keywords from an array. Once it detects any word in the array, it highlights it with a red background - everything is working smoothly so far. However, I now wish for the script ...

Locating the elusive sequence number within a document

Greetings, I am currently trying to locate a missing number within an xml file but seem to be encountering some challenges. Any suggestions or ideas would be greatly appreciated. Example The file contains an <a> tag with various ids such as page-1, ...

Ensure child elements do not surpass parent size in HTML/CSS/Javascript without altering the children directly

I am intrigued by how iframes neatly encapsulate all site data within a frame and adjust it to fit the size. Is there any method to achieve this functionality in an HTML wrapper? Can the wrapper be configured so that regardless of the content, it is dis ...

validating API keys in Django

What is the process for verifying API keys in Django? I am currently using RapidAPI and they provide a key, but how can I authorize it with the URL? views.py def thanks(request): url = "https://webknox-trivia-knowledge-facts-v1.p.rapidapi.com/trivia/r ...

Extracting PartialView contents as a string

I am looking to embed HTML code that is rendered by a PartialView. For instance, var partView = PartialView("myView", myModel); string content = ??; What should I replace the question marks with? ...

Learn how to manipulate the DOM by dynamically creating elements and aligning them on the same line

Providing some context for my page: The section I have always contains a single input field. Below that, there is an "add" button which generates additional input fields. Since only one field is required on the screen, the following fields come with a "de ...

Is there a way to display icons alongside each option in the dropdown menu?

I have a dropdown icon (pumpkin 1) div that is causing spacing issues with the other icons on the page. The problem is that it has a dropdown functionality which needs to overlay the text at the bottom. I want to display all icons next to each other (1,2, ...

Manipulating the .innerHTML property allows for selectively replacing sections

In my JavaScript code, I am trying to display a video along with a countdown timer. Once the countdown finishes, it should switch the content of the div to show a question. Below is my current implementation: <script type="text/javascript"> ...

The tab content refuses to show up in its designated fixed location

I've been working on creating a responsive tab system that functions as an accordion on smaller mobile devices, inspired by this example. I've made great progress and I'm almost where I want to be, but for some reason, the active tab content ...