Create a layout where a flexbox container is nested under another div and achieve the desired positioning

<style>
    .container{
        display: flex;
        gap: 5px;
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
        overflow:auto;

    }
    
    .container .one{
        background-color: blue;
        align-items: stretch;
       
        flex-basis: 300px;
       
       
    }
    
    .container .two{
        background-color: blue;
       
        flex-shrink: 30px;
        
    
    }
    .container .three{
        background-color: blue;
        
        flex-basis: 950px;
    }
    .four{
        background-color: blue;
        float: left;   }
</style>
<body>
   
</body>

Tips for Implementing Flexbox Layouts

I've been trying to create the layout outlined above using Flexbox, but I haven't been able to replicate it exactly. Can someone provide guidance on achieving this with Flexbox alone, without relying on floats or bootstrap?

Answer №1

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <style>
        * {
            margin:0;
            padding:0;
        }
        .container {
            display:flex;
            flex-direction: column;
            gap:20px;
            margin:10px;
        }
        .row {
            display:flex;
            gap:6px;  
        }
        .row:last-child {
            gap:0;
        }
        .top-boxes {
            background-color:rgb(6, 85, 124);
            border:4px solid black;
            text-align: center;
            height:400px;
            padding-top:20px;
        }
        .bottom-boxes {
            background-color:aqua;
            border:4px solid black;
            text-align: center;
            padding:14px;
            color:blue;
        }
        .top-boxes:nth-child(1) {
            flex-grow:2;
        }
        .top-boxes:nth-child(2) {
            flex-grow: 0.5;
        }
        .top-boxes:nth-child(3) {
            flex-grow: 5;
        }
        .bottom-boxes:nth-child(1) {
            flex-grow:5.5;
        }
        .bottom-boxes:nth-child(2) {
            flex-grow: 3;
        }
        .bottom-boxes:nth-child(3) {
            flex-grow: 1;
        }
    </style>
    <title>Document</title>
</head>
<body>
    <div class="container">
        <div class="row top">
            <div class="top-boxes">
                <h3>
                    Puzzled
                </h3>
            </div>
            <div class="top-boxes">
                <h3>
                    Joyful
                </h3>
            </div>
            <div class="top-boxes">
                <h3>
                    Gloomy
                </h3>
            </div>
        </div>
        <div class="row bottom">
            <div class="bottom-boxes">
                <h3>
                    Cozy
                </h3>
            </div>
            <div class="bottom-boxes">
                <h3>
                    Chilly
                </h3>
            </div>
            <div class="bottom-boxes">
                <h3>
                    Boiling
                </h3>
            </div>
        </div>
    </div>
</body>
</html>

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

The scrolling function halts as soon as the element that was middle-clicked is deleted from the

I am knee-deep in developing my own React virtualization feature and encountering a minor annoyance. When I middle click on an item in the list and start scrolling, the scrolling stops once that item is removed from the DOM. My initial thought was that the ...

In IE8, displaying an element with jQuery does not cause the footer to be pushed down

I've tried various methods to solve this issue, but none have been successful so far. To better illustrate my problem, I have created a FIDDLE. When the button is clicked, a hidden element is displayed. However, it does not adjust the footer position ...

Is there a way to automatically load a page?

Is there a way to automatically load another page without clicking on a link? I have a website with PayPal options available, and I want to know if there is a way to load the PayPal code without the need for a click. Can anyone help with this issue? < ...

Using the viewport meta tag in HTML and CSS within Laravel's Blade template while also

Greetings everyone! I have a question regarding Blade Laravel: Can we add a condition to the meta name="viewport" content="width=device-width, initial-scale=0.4"? I want the scale to start at 0.4 for smartphones and at 0.6 for tablets. ...

Clearing selections from a multiple-choice input field

I am seeking to implement a delete feature in a multi-select element similar to the functionality seen here on stackoverflow when selecting multiple tags for a question. Once an item is selected, I would like to display a close icon next to it so that user ...

Close button located in the upper-right corner is partially cut off

My challenge involves placing a close button on the top right corner of a #main div that contains an image of varying or larger size. I need the close button to slightly protrude outside the div using negative margins. The issue is that when I use overflow ...

Unable to fetch the data from HTML input field using autocomplete feature of jQuery UI

I am facing an issue with my html autocomplete textbox. Whenever I try to enter an address like "New York" and click on the submit button, it does not retrieve the input value and returns no value. Test.aspx <!--Address--> <div class="form-g ...

Retrieve custom attributes of child elements using jQuery selectors

I am looking to modify the data-answersetid attribute of all child controls under the .cloneable class in a table. Each row in the table contains a single control - either a textarea, checkbox, radio button, or input[type=number]. Each control has a custom ...

Updating the color of tick marks on checkboxes

I have successfully updated the background color of my checkboxes using a custom function. However, the tick mark on the checkbox now turns black instead of remaining white. How can I keep the tick mark white while changing the background color? Here is t ...

Incorporate a dropdown menu based on the selection made in another dropdown menu

I have a scenario on my website where I want to dynamically add select boxes based on the value selected in the previous one. Here is the code snippet: <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"> </script> & ...

Can a stroke in an SVG image be created using a gradient color?

Is it possible to create a gradient in the stroke color of these two lines, currently set to #389967, within this SVG? .chart-three svg .circle-foreground { stroke: #389967; stroke-dasharray: 494.55px 549.5px; stroke-dashoffset: 494.55px; stroke- ...

I require fixed headers that no longer stick once reaching a specific point

I have a setup where the names and occupations of participants are displayed next to their artworks, and I've made it sticky so that as we scroll through the images, the names stay on the left. Now, I want the names to scroll out once the images for e ...

Tips for designing rainbow-themed elements (hyperlinks) using CSS to incorporate multiple colors

When customizing link styles in D3.js, it's common to adjust the color of the links. For instance, in the code snippet below, I've created thick links with a width of 10 and colored them grey. link = svg.append("g") . . . .style("stroke", "grey" ...

When the IF condition in HTML is used in conjunction with Java code, it is causing all HTML code to be ignored and

Everything works perfectly if "sh" has a value (such as "Day" or "Night"), but when it is empty or null, it triggers a null condition and skips all the code on my HTML page, leading the control to the end of the HTML file. Question: I have tried using els ...

Modify components in a web application based on the content of a JavaScript variable

I'm in the process of developing a webapp that needs to interact with an Arduino for its inputs in order to dynamically change the contents of the webpage. Currently, I am experimenting with variables that I have created and assigned random numbers t ...

The stop-color property is not functioning as expected in CSS/SVG

Here is the code I am currently working with: <?xml version="1.0" standalone="yes"?> <svg xmlns="http://www.w3.org/2000/svg" width="360" height="240"> <style>stop{stop-opacity:1}circle{fill:url(#r)}</style> <defs> <radialG ...

"Using html_attr with the attribute "href" does not return any value in the rvest package

My objective is to extract the URLs linked with specific CSS elements on a website using rvest. Despite trying various methods, such as using the html_attr function with the 'href' argument, my current script only returns NA values instead of the ...

The refreshed Google Chrome cache post-update on the Developer Dashboard

With each new Google Chrome update, developers experience a mix of benefits and drawbacks. Lately, I have noticed a change in how Chrome handles caching, with everything being cached successively without any disassembly. For instance: When working on a we ...

Guide to implementing a seamless Vue collapse animation with the v-if directive

Struggling with Vue transitions, I am attempting to smoothly show/hide content using v-if. Although I grasp the CSS classes and transitions involved, making the content appear 'smoothly' using techniques like opacity or translation, once the anim ...

a pair of columns next to each other

I am having trouble getting two lists to display side by side. The second list keeps appearing below the first list. I need them to be in separate divs because they will have different colors and content. Additionally, the lists will be dynamically populat ...