Achieving a layout with two rows containing two flexboxes on each row using Flexbox

Currently, I'm working on getting two flexboxes on each row. Here is the current layout:

https://i.sstatic.net/UsAI6.jpg

Here is the desired layout I'm aiming for: https://i.sstatic.net/wRhw4.jpg

I want to have 4 flexboxes in total, with 2 on each row. The first and third should have the same width, while the second and fourth should also have the same width. I've been experimenting with different options but haven't found the right solution yet. Any recommendations?

.left {
  background: #808080;
  flex-grow: 1;
  order: 1;
  color: white;
  font-family: Arial, Helvetica, sans-serif;
  flex-wrap: wrap;
  flex-direction: row;
  width: 25%;
}
.left,
.right {
  margin: 20px 20px;
  border-style: solid;
  border-color: black;
  border-width: 5px 5px 5px 5px;
}
.left.fixedsize {
  flex-basis: 25%;
}
.second img {
  margin: auto;
  display: block;
  padding-bottom: 10px;
  padding-top: 10px;
}
/*ADD-BUTTON*/

.left.fixedsize button {
  margin: auto;
  display: block;
  color: black;
  background-color: white;
  padding-bottom: 10px;
  padding-top: 10px;
  border-style: solid;
  border-color: black;
  border-width: 2px 2px 2px 2px;
  border-radius: 15px 15px 15px 15px;
}
.left.fixedsize button:hover {
  color: orange;
}
/*RIGHT*/

.right {
  background: #808080;
  flex-grow: 1;
  order: 1;
  color: white;
  font-family: Arial, Helvetica, sans-serif;
  flex-wrap: wrap;
  flex-direction: row;
  width: 75%;
}
.right h1 {
  margin-top: 20px;
}
.fixedsize {
  flex-basis: 75%;
}
.third img {
  padding: 10px;
}
<!--LEFT-->

<main>

  <div class="left fixedsize">
    <ul class="second">

      <li>
        <img src="TheIntouchables3.jpg" width="265" height="400" align="middle">
      </li>
      <li>
        <img src="TheIntouchables1.jpg" width="265" height="400" align="middle">
      </li>
    </ul>
  </div>

  <!--RIGHT-->


  <div class="right fixedsize">
    <h1>The Intouchables</h1> 


    <p>FRA 2011 (112 min)
      <br>Olivier Nakache / Eric Toledano
      <br>
    ...
    (Additional content)
    ...
    <br>
    <br>Watch trailer <a href="https://www.youtube.com/watch?v=34WIbmXkewU">HERE</a>
    </p>

    <ul class="third">
      <li>
        <img src="TheIntouchables2.jpg" width="600" height="385">
      </li>
    </ul>


  </div>
  </div>
  </div>

</main>

Answer №1

Here is a simple example:

.container {width: 100%;display:flex;}
.left{flex:1; height:100px;}
.right{flex:3; height:100px;}
<div class="container">  
     <div style="background-color:gray;" class="left">       </div>
     <div style="background-color:red;" class="right"></div>
    </div>
<div class="container">
    <div style="background-color:yellow;" class="left"></div>
    <div style="background-color:green;" class="right"></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

Guide on creating an Iframe in HTML with JavaScript

Can someone help me troubleshoot why the following code isn't working to write an iframe into HTML using JavaScript? <html> <body> <script> document.write("<iframe width="560" height="315" src="https://www.youtube.com/embed/9Ow8 ...

Improprove the performance of external banner ads by utilizing asynchronous loading or caching techniques

My website is slick, elegant, and loads quickly - that is until the banner ads come into play! A delay of up to 10 seconds in loading occurs due to waiting for the ads, which is frustrating considering the effort I put into optimizing the rest of the site. ...

Utilizing Material UI's React framework for maintaining uniform grid column heights

Take a look at the image provided for context. I am facing an issue with two div elements, where one should occupy 20% of the total browser height and the other should take up 80%. Currently, I am utilizing Material UI Grid for positioning, which looks lik ...

Trigger the datepicker to open by clicking anywhere within the TextField in MUI

I am trying to enhance my date picker functionality by displaying it when users click anywhere within the field, not just on the calendar icon. Below is the picker: https://i.stack.imgur.com/mrAui.png export function DatePickerField(props) { ...... ...

How to override an event in JavaScript when a specific value is entered

I am looking to implement a system with complex conditions. The goal is to have an alert appear when a value is inputted and the button is clicked. First, a confirmation message Have you input ? should be displayed, followed by clicked with input. If no va ...

Is there a way to manually change the field color upon approval in AngularJS?

Within my application that utilizes the MEAN stack, I am using AngularJS as the front-end technology. How can I manually change the color representation of a tolerance value to 159.06 in a table? Check out my Plunker for more details. Please refer to m ...

transforming unicode into regular characters prior to being presented on a webpage

I am currently utilizing the openinviter class to import contacts from emails. Sadly, it is showing Unicodes of non-English characters, like Polish, such as u0117 (and similar code types), instead of regular characters. Is there a way to convert these Unic ...

The toggling feature seems to be malfunctioning as the div section fails to display

I'm facing an issue with my Django project while working on a template. I want to toggle the visibility of a div element between hiding and showing, but the function I used isn't working for some reason. I borrowed the function from a different t ...

Display HTML using JavaScript/jQuery

I am trying to figure out how to print a document by passing custom HTML code. Below is the code I have tried, but unfortunately it's not working: function Clickheretoprint() { var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes, ...

Using Vue and vue-multiselect to create interactive options based on the selected language

I'm currently developing a Vue website with multilingual support. The chosen language is stored in a Vuex store and accessed through the computed property lang, like so: lang(){ return this.$store.state.lang } I use this lang property in v-if cond ...

Troubleshoot: Unable to Change CSS on Click Using Javascript/jQuery

Having trouble creating three different buttons that toggle between various images using the CSS display property? Check out my code on https://jsfiddle.net/agt559e8/. function USradarChange1() { //document.getElementById("usradar1").src="weather/curr ...

Cystoscape has ventured beyond the limits of the canvas border

I am trying to confine the objects within the cytoscape canvas so they do not move outside of the maximum width and height. However, when I drag the objects within the canvas, they go outside of the canvas border: https://i.sstatic.net/Su4PE.png Currentl ...

Caution: Unable to establish connection with database due to connection refusal (HY000/2002)

Currently diving into PHP and working on a login/register page in localhost using XAMPP on my Mac. I'm encountering an issue with the following error message: Warning: mysqli_connect(): (HY000/2002): Connection refused in /opt/lampp/htdocs/website/ ...

Making the black background stretch to the full height and allowing for scrolling when necessary

Check out this webpage where the text in the box extends beyond the page when scrolling, revealing the full content while the black background expands correctly. Visit this page to see that the text in the box is small, but I want the black background t ...

"Designing with Vue.js for a seamless and adaptive user experience

I'm looking to customize the display of my data in Vuejs by arranging each property vertically. Instead of appearing on the same line, I want every item in conversationHistory to be displayed vertically. How can I achieve this in Vuejs? Can anyone off ...

Issues with CSS animations and transformations on SVG files are not being resolved

I've been attempting to create a transform animation using an SVG file, but unfortunately, the animation or transform isn't functioning at all. I've taken the time to research this issue, however, I haven't found a solution yet. Can any ...

Apply a specific class only when the user scrolls within the range of 200px to 300px

Is it possible to dynamically add a class to a div element based on the user's scrolling behavior? For example, I would like to add a class when the user scrolls 200px down the page, and then remove it when they scroll 300px down. Similarly, I want to ...

What is the best method to modify and access imported .css files within the WordPress style.css file?

I could use some assistance with a project involving minor edits to a WordPress website. I've hit a roadblock and need some help. The style.css file in WordPress doesn't have much CSS code, but instead imports files like this: /*Animate*/ @impo ...

Obscured Background Beneath the Bootstrap Tip

Desired Outcome: I am aiming to achieve a blurred background behind the tooltip element. https://i.sstatic.net/AE1RQ.png Current Status The current state shows that the area behind the tooltip is not blurred as intended. https://i.sstatic.net/bE57E.pn ...

Why is the editor not displaying the correct line number when the enter key is pressed repeatedly in JavaScript?

I am currently working on developing an editor using JavaScript. My goal is to display a line count (e.g., 1, 2, 3) whenever the user presses 'Enter' to change lines. I have successfully managed to count the line changes upon pressing 'Enter ...