What is the best way to structure layout blocks using the CSS attribute "display:flex;"?

I recently made the decision to implement the new CSS property "display:flex;" in one of my projects. Despite reading numerous articles on the topic, I was unsure whether it was possible to create a layout using this property without compromising the integrity of the HTML code.

Here is a preview of what I am working on:

.container {
    width:910px;
    display:flex;
}

figure {
    position:relative;
    width:300px;
    height:180px;
}

figure:first-child {
    width:600px;
    height:370px;
}

figure:first-child figcaption {
    width:590px;
}

figure figcaption {
    position:absolute;
    z-index:10;
    bottom:0;
    left:0;
    padding:5px;
    width:290px;
    background-color:rgba(0,0,0,.3);
}
<div class="container">

    <figure>
        <img src="http://placehold.it/600x370" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>
    
    <figure>
        <img src="http://placehold.it/300x180" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>
    
    <figure>
        <img src="http://placehold.it/300x180" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>

</div>

If you want to see the code in action, check out the link to the JSFiddle

Please excuse any language errors in my explanation.

Answer №1

Check out the updated version with CSS columns implemented: https://jsfiddle.net/vzjhybh0/4/

    <figure>
        <img src="http://placehold.it/600x370" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>

    <figure>
        <img src="http://placehold.it/300x180" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>

    <figure>
        <img src="http://placehold.it/300x180" alt="">
        <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figcaption>
    </figure>

</div>

.container {
    width:1100px;
    height:400px;
     -webkit-columns: 2;
}

figure {
    position:relative;
    width:300px;
    height:180px;
}

figure:first-child {
    width:600px;
    height:370px;
}

figure:first-child figcaption {
    width:590px;
}

figure figcaption {
    position:absolute;
    z-index:10;
    bottom:0;
    left:0;
    padding:5px;
    width:290px;
    background-color:rgba(0,0,0,.3);
}

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

Is there a way to continuously update a Bootstrap progress bar using information retrieved from my PHP script?

I currently have a bootstrap progress bar displayed on my webpage. <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%"> 70% </div> </div& ...

Troubulating with overflow-y: scroll functionality? Follow these steps to troubleshoot

I've been working on a project involving the .menu-scroll class, which is a div within a <ul> list. I want this div to display a scroll bar when it exceeds its height limit. However, instead of achieving this, it keeps pushing down the .menu-foo ...

Enhance Your HTML Skills: Amplifying Table Display with Images

Recently, I utilized HTML to design a table. The Table Facts : In the first row, I included an appealing image. The second row contains several pieces of content. In continuation, I added a third row. The contents in this row are extensive, resulting i ...

Blogger website experiencing issue with Slick slider not automatically playing

I recently downloaded and customized the Slick Slider from the Slick Slider website and got it working perfectly on my local machine. However, when I added it to a blog website on blogger.com, I noticed that the auto play feature was not working and the n ...

Tips on modifying the color of three distinct tooltip arrows

I managed to give 3 tooltips different colors using JavaScript and data-toggle like this <span class="tooltipjs" data-toggle="sin-datos" data-placement="right" data-original-title="some text">A</span> $( ...

PHP: Using simple_html_dom to locate the content within a span element having a specific class

If we have an HTML structure similar to this: (...) <div class="UserLevel type_2"> <span class="LevelNum">23</span> </div> (...) What is a simple way to extract the value 23 and store it in a PHP variable using simple_html_dom ...

Using div elements to mimic the layout of tables with row spans

<div class="container"> <div class="box1">1</div> <div class="box2">2</div> <div class="box3">3</div> </div> .box1 { border: 1px solid red; float: left; width: 20px; } .box2, .box3 { ...

AngularJS includes a feature where you can dynamically add elements to the DOM by

My goal is to create a dynamic table where clicking on an element will display details in the next line. Here is my implementation: <table ng-controller="TestCtrl"> <tr ng-repeat-start="word in ['A', 'B', 'C']"&g ...

Populating a text area using HTML and displaying &lt; instead of <

I developed a small editor for managing resource files. Within this editor, I display the content of a specific resource item in a textarea: <textarea cols="85" rows="12" id='EditItemTextArea'><%# Eval("Translation")%></textarea& ...

Attempting to create a 6x6 game board using a 2-dimensional array

As a newcomer in the world of coding, I am currently working on completing my year 1 project titled "6x6 Reversi Chess." Right now, my main focus is on constructing the chess board using a 2D array. However, I am facing challenges when it comes to incorpor ...

Effortless jQuery Parallax

Seeking assistance with debugging this jQuery code that manipulates the top margin of an element within a container. The container has a fixed size and overflow set to hidden to create a parallax effect. The parallax effect is functioning properly, but it ...

Ways to showcase a list in 3 columns on larger screens and 1 column on smaller screens

When viewing on a computer, my list appears like this: https://i.sstatic.net/fNhaP.png However, when I switch to a phone, only the first column is visible and the list does not continue in a single column format. I am utilizing Bootstrap for my layout, a ...

jQuery's remove/add class functionality seems to only function once

I haven't had much sleep and I'm not sure if toggleClass will work for this situation. Here is the code I currently have: $(document).ready(function() { // Slide Mobile Filter Sidebar Onto Screen $('#showFilters').on('clic ...

Seeking ways to ensure my component maximizes available space using Tailwind CSS

I am currently utilizing Tailwind CSS to style a Angular application. The setup is fairly straightforward: app.component.html is responsible for displaying a navigation bar and footer, while the components are shown in the remaining space with an overflow- ...

Children of flex items sharing the same height

I'm struggling with creating a flexbox responsive grid and need some guidance. My goal is to make all the .block divs have equal height, with the .bottom div positioned at the bottom. The current solution achieves this, but when the h2 heading spans ...

Are there any illustrations of a Keygen available?

I have been searching for a practical example showcasing the utilization of the keygen element, but all I come across is just echoing back the public key. Is there an actual demonstration available? Perhaps something like real authentication? ...

What is the best way to enable this image lightbox to function seamlessly with both horizontal and vertical images?

Looking to create a responsive image lightbox? After starting from an example on W3Schools (https://www.w3schools.com/howto/howto_js_lightbox.asp), I ran into issues with portrait oriented images. Ideally, the solution should handle both landscape (e.g., 1 ...

Creating a Multi-Step Checkout System for a WooCommerce Store

Struggling to make my code work - it just won't fire up. I suspect there might be a version-related issue that I'm overlooking. I'm currently using the default checkout setup from the WooCommerce plugin. Instead of buttons, text is showing ...

Refreshing data causes the data to accumulate and duplicate using the .append function in Jquery

I am currently working with a dynamic table that is being populated using AJAX and jQuery. Everything seems to be functioning correctly, however, I am encountering an issue when trying to reload the data as it just continues to stack up. Below is the func ...

Custom form validation in Angular 2 will activate once the user has emptied the textbox

Hello, I have been facing an issue with validating my input box as soon as it loses focus. Strangely enough, the validation message only shows up when I enter text into the textbox and then delete it. Below is my HTML template: ...