Flexbox allows for a unique custom layout design for your gallery

I'm having some difficulty implementing a gallery layout using flexbox.

https://i.sstatic.net/cGplk.png

Currently, my code is displaying two small images along with the large one in the top row, and then placing the remaining two small images in the bottom row.

Answer №1

Here is an example of how you can achieve a responsive layout using CSS flexbox.

.wrapper {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
}

.item {
  width: 100%;
  margin: 1em;
}

.content {
  border: 1px solid black;
  margin-bottom: 1em;
  height: 100%;
}
<div class="wrapper">
  <div class="item">
    <div class="content">half</div>
    <div class="content">half</div>
  </div>
  <div class="item content">full</div>
  <div class="item">
    <div class="content">half</div>
    <div class="content">half</div>
  </div>
</div>

Answer №2

Creating a Layout with Flexbox

        <div class"wrapper">
            <div class="leftColumn"></div>
            <div class="centerColumn"></div>
            <div class="rightColumn"></div>
        </div>

Custom Styling with CSS

.wrapper{
 width: 100%;
 display: flex;
 justify-content: space-between;
 align-items: stretch;
}

.leftColumn{
 display: flex;
 justify-content: space-between;
 height: 100%;
 flex-direction: column;
 align-items: stretch;
}
.rightColumn{
 display: flex;
 justify-content: space-between;
 height: 100%;
 flex-direction: column;
 align-items: stretch;
}

Now populate the columns with content, this setup should work properly

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

Enhance your website's user experience with jQuery by implementing smooth scrolling alongside

I have a fixed header at the top of my page. When it scrolls, I want to ensure that it does not cover or hide any of my content, especially the top portion of the section. // This code enables smooth scrolling (source: css-tricks) $('a[href*="#"]:no ...

Failure to Connect HTML with Stylesheet

Feeling a bit lost here. I've been attempting to connect my homepage to my stylesheet, but no matter how often I refresh the page, it just won't recognize the link. I'm diligently following the instructions from the guide I have, copying and ...

The table refuses to load

I've been troubleshooting this issue for the past two days. The array is visible in the console, but it refuses to show up on the table. I've tried multiple approaches, but none seem to work. I suspect that "tobodyHtml" is not defined properly, a ...

Structure: Divergent Routes

I have been developing a form for my job, using some code I found online. The form starts by asking a simple question: Does the student have an ID? The answer is toggled between "YES" and "NO". If "Yes" is selected, the form will retrieve student informati ...

Is there any benefit to making the SVG elements width and height 100%?

The Angular Material documentation app features an SVG Viewer that is able to scale the SVG content to fit the container using the following function: inlineSvgContent(template) { this.elementRef.nativeElement.innerHTML = template; if (this.sca ...

Removing a modal div element in React after navigating

import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axios from "axios"; import Cookies from "js-cookie"; const LoginPage = () => { const [email, setEmail] = useState( ...

Positioning Arrows Adjacent to Definitions

I have a PHP snippet that adds arrow indicators next to previous and next sections on a page. This allows users to easily navigate between sections by clicking on the arrows. The desired output format is: (arrow) Previous Section Next Section ...

Move a single <div> element according to the screen resolution

I'm a beginner in coding and struggling with a specific problem. I need to adjust the position of a container based on screen size. For large and mid-sized screens, the container needs to be left-justified with a small amount of padding from the left ...

Having numerous calls to isNaN within a JavaScript if-else statement

I've created a JavaScript function that generates div elements and styles them based on user input values. However, I'm facing an issue when trying to display a warning message if the input is not a number. Currently, I'm unable to create th ...

The iframe came to a halt as soon as it was no

I am currently developing a live video website that utilizes third-party tools to play the videos. To simplify things, I have embedded all the components required for live video into a single HTML page. Here is how it looks: <iframe data-v-140cfad2= ...

What is the best way to add multiple lines of text to a webpage using the span element?

Currently, I am developing a game that involves using a map, which consists of multiple lines. My question is whether it is possible to have the span tag cover multiple lines while ensuring that each line ends with a new line character. Below is an exampl ...

Retrieve data from a specific page on a URL using AJAX

window.onload= function(){ var page = window.location.hash; if(window.location.hash != ""){ page = page.replace('#page:', ''); getdata('src/'.page); } } Once the window has loaded, I want to check ...

Unable to create a universal <header> and <footer> to be displayed across all pages

After trying to separate the <header> and <footer> into external files, everything seemed to work fine in the console. However, when running the code, it ended up returning undefined. This is the HTML for the Footer: <footer id="footer ...

Updating a URL in an HTML form with JavaScript

Currently, I am faced with the task of manipulating a variable's value in a JS file within a function that is responsible for dynamically updating values in an HTML table without necessitating a full website reload. The function code snippet appears b ...

Stop the click event from firing on child elements of a parent element that is currently being dragged

Below is the structure of a UL tag in my code: <ul ondrop="drop(event)" ondragover="allowDrop(event)"> <li class="item" draggable="true" ondragstart="dragStart(event)" ondrag="dragging(event)"> <div class="product-infos"> ...

Ways to position 4 containers next to each other using CSS

I need help aligning 12 buttons in a specific layout: 4 buttons on the top and 3 on each side to total 12 buttons. Also, I want 2 additional buttons at the top left (Div/Mult) and top right (Add/Sub). Below, you'll find the HTML and CSS documents. If ...

Tips for implementing a search filter in a select dropdown menu using Angular

I am attempting to enhance my select option list by including a search filter. With numerous options available, I believe that having a search function will make it easier for the user to locate their desired selection. I hope my message is clear despite ...

How can one retrieve the 'alt' attribute text from an image tag on a webpage using the JSOUP library in an Android application?

Extracting the 'alt' text from an 'img' tag in Android after clicking a button is causing issues. The attempted code is not working as expected. Here is the snippet of the code that was used: Document doc = Jsoup.connect(url).get(); ...

What is the best way to implement validation in a textarea to restrict the word count to a minimum of 250 and a maximum

I want to implement jQuery validation for a textarea field, with a requirement of 250 minimum words and 1000 maximum words. Additionally, I need to display the word count in a span tag next to the text area. How can I ensure that this validation works even ...

Learn how to maintain floating labels in a floating state even after text input using only CSS

Figured out how to make labels float above form input fields when focused, but struggling with keeping them floating when text is entered and field is unfocused. Been searching for CSS examples online, but none seem to clarify how to achieve the desired e ...