Challenge involving flexbox and several squares, along with a @media adjustment for screens under 600px wide

I'm feeling a bit overwhelmed with this flexbox assignment I need to complete.

The desired outcome should resemble the image here: https://i.sstatic.net/XKvPk.jpg When the screen is at or below 600px, the two blue squares should move beneath the red square. The text content must remain unchanged. The container's standard size is 600px by 500px and needs to be centered. For reference, please check out the codepen link provided: https://codepen.io/anon/pen/RQrmvE

* { 
  box-sizing: border-box 
} 
.flexbox {
  margin:auto;

}
.flexbox {
  width: 600px;
  max-width: 100%;
  height: 500px;
  background-color: black;
  display: flex;
  justify-content: space-around;
 align-items: flex-start;
   flex-wrap: wrap; 
font-size:3em;

}

.flex-item {
  width: 100px;   
  color: white;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;

}

#flex-item-1 {
  background-color: yellow;
  height: 100px;
margin-top:20px;;
width:260px;
}

#flex-item-2 {
  background-color: green;
   height: 100px;
margin-top:20px;
width:260px;
}

#flex-item-3 {
  background-color: red;
  height: 350px;
width:350px;
margin-left:14px;
word-wrap:break-word;
}

#flex-item-4 {
  background-color: skyblue;
  height: 80px;
width:150px


}

#flex-item-5 {
  background-color: skyblue;
  height: 80px;
align-self:flex-start;
margin-bottom:20px;

}

Answer №1

Hopefully this meets your expectations - View on CodePen

* {
  box-sizing: border-box;
}

.flexbox {
  width: 600px;
  max-width: 100%;
  height: 500px;
  background-color: black;
  display: flex;
  margin: 0 auto;
  padding: 25px;
  flex-wrap: wrap;
  font-size: 3em;
}

#flex-item-1 {
  background-color: yellow;
  height: 100px;
  width: 48%;
}

#flex-item-2 {
  background-color: green;
  height: 100px;
  width: 48%;
  margin-right: 0;
  margin-left: auto;
}

#flex-item-3 {
  background-color: red;
  height: 320px;
  width: 350px;
  margin-top: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#flex-item-4 {
  background-color: skyblue;
  height: 150px;
  width: 175px;
  margin: 25px 0 0 auto;
}

#flex-item-5 {
  background-color: skyblue;
  margin: -150px 0 0 auto;
  display: flex;
  height: 150px;
  width: 175px;
}

@media (max-width: 600px) {
  #flex-item-1,
  #flex-item-2 {
    height: 80px;
  }

  #flex-item-3 {
    height: 160px;
  }

  #flex-item-4,
  #flex-item-5 {
    height: 70px;
  }

  #flex-item-5 {
    margin-top: 25px;
  }

  #flex-item-3,
  #flex-item-4,
  #flex-item-5 {
    width: 100%;
  }
}

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 is the purpose of using a visually striking and prominent HTML tag?

After 15 years of working in html development and managing multiple websites, I have come to realize that bold and italic tags essentially serve the same purpose. I can apply CSS styles to both to achieve similar effects. I have even experimented with maki ...

Unrecognized files located within the same directory

My main.html file located in the templates folder also contains three additional files: date.js, daterangepicker.js, and daterangepicker.css. Despite including them in the head of the HTML as shown below: <script type="text/javascript" src="date.js"> ...

What is the best way to implement JavaScript for loading and removing content based on button clicks on a webpage?

I'm in need of a vanilla JavaScript solution (I know JQuery options exist, but I want to stick to vanilla JS for now)? Currently, I am using a simple page as a testing ground for my ongoing project. The page consists of two buttons that load HTML pag ...

Positioning an image on the right side of text

I am struggling to align the image to the right side of the text. Despite trying various methods, the image keeps appearing below the text instead of alongside it. Although I believe my code is correct, the desired outcome is not being achieved. To view ...

Storing External Cached Data

I am facing an issue while trying to save cached webView files to a specific directory on the SD-card. I have set up HTML5 and a cache-manifest file on the server. Despite using the setAppCachePath method to designate an external directory on the sd card, ...

Following the recent update of Google Chrome, Sencha Touch experiences spinning issues

Since updating my Google Chrome to the latest version (v29.0.1547.57 m), I've noticed some issues with parts of my Sencha Touch app spinning. The Sencha Touch version I am using is v2.2.1. For example, when using Ext.Msg.alert, I can see the title bu ...

retrieving the selected date from the calendar widget

I'm utilizing jQuery's datepicker to collect date inputs from users. The form is structured as below: <form id="myform" action="/graphs/get_builds" method="post"> Start: <input type="text" id="start" /> End: <input type="t ...

Is there a way to locate the final <li></li> within each <ul></ul>? (Regarding front-end development, specifically dealing with html, css, and jquery)

I'm dealing with a menu that has submenus of its own. Issue: Upon loading the page, I notice that the website is adding an extra letter S at the end of each submenu. How can I eliminate that letter S from the end of every submenu using JQuery or CS ...

Expanding across the entire horizontal space, excluding any space allocated for

I've been on a quest to find a solution for my unique problem, but all my efforts have been in vain so far. Currently, I'm working on developing a mobile website and facing a challenge with the input boxes. Despite wanting them to take up the en ...

Getting the value of the chosen option from one component and passing it to another component in Angular 8

How can I pass the selected option value from the login component to the home component without using local storage? When an option is selected in the login component, I want that value to be displayed in the home component. Below is the code snippet: Lo ...

Asking for information regarding RESTful API

Could you please assist me in identifying the most suitable technologies for integrating a RESTful API into an HTML and CSS website? The primary objective is to enable the website owner to easily log in and add news entries about their business. Addition ...

Tips for creating a vintage, weathered font appearance on a web browser

Is it possible to create unique, randomly outwashed letters using a standard font? Instead of relying on pre-designed outwashed fonts available at , I am interested in achieving the same effect with a regular font that appears washed out when displayed in ...

Updating the source of an iframe when the linked file is modified or updated

Currently, I am in the process of developing a page named live_link_frame.php. This page includes loading an iframe through a URL retrieved from a local file called live_link.txt: <?php $filePath = 'live_link.txt'; $handle = @fopen($filePath, ...

Guide on extracting a particular HTML attribute and storing it in a variable

Perhaps the title is not worded correctly, but I needed help with using beautifulsoup4 to scrape data and thankfully received assistance from someone. import requests from bs4 import BeautifulSoup import re #NJII params = { 'action': &apo ...

Loading Website Content, Track your Progress

I'm facing an issue with the website loading progress bar. The script I'm using for the progress bar is not functioning correctly on the Web server www.example.com. Even though the website is live on the web server, the problem is that the progre ...

Is less.js capable of compiling CSS code that is compatible with all browsers?

Is there a simple way to convert my Less code into browser-compatible CSS like the example below? #grad1 { background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */ background: -o-linear-gradient(red, blue); /* For Opera 11.1 to ...

I am interested in incorporating a delete button within my Angular application

I am working on an Angular App and I need to implement a remove button for a div element. Currently, I have an add button function in my ts file: uploads = []; addUp() { this.uploads.push(this.uploads.length); } I attempted to create the remove b ...

Manipulating values in JavaScript using an onclick event in PHP

I am looking to remove the "http" from the URL part of an input link before sending the data. This is my input code that looks like this when clicked: <input style="outline: none;" type="button" onclick="formatText ('link:url');" class="btn ...

Foundation's inner-margin for columns

I need some help with adjusting the layout of a row in two columns. My goal is to have the columns span the full width of the row with a margin between them to maintain alignment with the surrounding rows. The default settings are not ideal as they add ma ...

What is the process for inserting a div with an identifier when my check box is selected?

I'm currently working on a dynamic table with table cells that contain checkbox inputs. These checkboxes switch the text between "Available" and "Blocked" depending on whether they are checked or not. I am now trying to add a div with an ID that will ...