Is there anything I can modify in either the HTML or CSS code to achieve the desktop layout I envisioned?

I have been striving to replicate this https://i.sstatic.net/B0Qkb.jpg desktop design.

The mobile version has already been crafted, but when I attempt to adapt it for desktop, I'm utilizing a specific flex property called row-reverse. However, the outcome turns out like this: https://i.sstatic.net/xTN9B.jpg

I am currently puzzled about how to adjust the positioning to match the desktop design and have been grappling with this issue for the past few days.

Could someone kindly enlighten me on what I might be doing wrong and provide guidance on resolving this problem?

@import url('css-reset.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Lexend+Deca&display=swap');

:root {
    --color-main-background: hsl(233, 47%, 7%);
    --color-card-background: hsl(244, 38%, 16%);
    --color-soft-voilet: hsl(277, 64%, 61%);
    --color-white-main: hsl(0, 0%, 100%);
    --color-white-paragraph: hsla(0, 0%, 100%, 0.75);
    --color-white-stats: hsla(0, 0%, 100%, 0.6);
    --font-weight-four: 400;
    --font-weight-seven: 700;
}

body {
    background-color: var(--color-main-background);
    font-weight: var(--font-weight-four);
    color: var(--color-white-main);
    margin: 0;
}

.container {
    display: grid;
    grid-auto-flow: row;
    border-radius: 10px;
    justify-content: center;
    text-align: center;
    align-self: center;
    max-width: 350px;
    min-height: 750px;
    margin-top: 30px;
    margin-left: auto;
    margin-right: auto;
  
    background-color: var(--color-card-background);
    overflow: hidden;
}


picture>* {
    width: 100%;
    max-height: 100%;
    object-fit: cover;

...
</body></html>

Answer №1

Hopefully, this guide will assist you in restructuring your section.

I attempted to recreate your design by taking a slightly different approach:

To begin with the main div (container), I divided it into two child divs by applying d-flex to the container for alignment purposes. Within the left div, I created two additional divs: one containing the header and paragraph, and the other housing the three stats and heading. My recommendation would be to wrap each stat and heading in its own div, allowing for proper alignment across desktop and mobile devices using d-flex and related flex-direction properties.

    html,
        body {

            height: 100%;
        }

        div {
            border: 2px solid red
        }

        .container {
            display: flex;
            align-items: center;
        }

        .box-left {
            width: 50%;
            background-color: blueviolet;
            height: 500px;
            display: flex;
            flex-direction: column;
            justify-content: center;


        }

        .box-right {
            width: 50%;
            background-color: brown;
            height: 500px;
            width: 50%;
            background-image: url(https://images.pexels.com/photos/3184360/pexels-photo-3184360.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1);
            background-size: cover;

        }

        .box-bottom {
            display: flex;
            justify-content: space-between;
        }

        .text-wrapper {
            padding: 50px;
        }


        @media (max-width:768px) {
            .container {
                flex-direction: column-reverse;

            }

            .box-left,
            .box-right {
                width: 100%;
            }

            .box-left {
                text-align: center;
            }

            .box-bottom {
                display: flex;
                flex-direction: column;
                justify-content: center;
            }
        }
<body>
    <div class="container">
        <div class="box-left">
            <div class="text-wrapper">
                <div>
                    <h1>Your title here</h1>
                    <p>It is a long established fact that a reader will be distracted by the readable content of a page
                        when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal
                        distribution of letters, as opposed to using 'Content here, content here', making it look like
                        readable English.</p>
                </div>
                <div class="box-bottom">
                    <div>
                        <h2>10k</h2>
                        <p>SOMETHING</p>
                    </div>
                    <div>
                        <h2>10k</h2>
                        <p>SOMETHING</p>
                    </div>
                    <div>
                        <h2>10k</h2>
                        <p>SOMETHING</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-right">

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

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

Tips for configuring a file using javascript and angular.js

I am in need of some assistance. I would like to create a configuration file that stores all the paths for JavaScript files, which can then be dynamically called and included in the index page using Angular.js or JavaScript. The structure of my files is ex ...

Expand the div to fit one side of the browser

My bootstrap code looks like this: <div class="container"> <div class="row"> <div class="col-md-8">content</div> <div class="col-md-4"> <div class="map">map goes here</div> </div> </div& ...

How can I use XPATH and Python Selenium to select the text node that is outside of an <a> element?

Check out the following link: Within this section of code: //*[@id="main-contents"]/div[1]/table[1]/tbody/tr/td, there is a piece of text Mottled Boar slain (10) //*[@id="main-contents"]/div[1]/table[1]/tbody/tr/td/a This part contains only: Mo ...

The seamless integration of React.js with HTML

My friend and I are beginners in the world of programming, with a solid grasp of html, CSS, and JavaScript. We're currently collaborating on a small project where we aim to create a chat system. While researching resources for our project, we came acr ...

Choose the first element of its type and disregard any elements nested within it

I need to change the color of only the first p element within a specific div. Using :first-child would work in a simple example, but in my project, there are multiple elements and more could be added in the future. I want to avoid using :first-child alto ...

What are the steps for incorporating validation in bootstrap 4 css?

I came across this interesting example in the documentation for bootstrap 4: <div class="form-group has-success"> <label class="form-control-label" for="inputSuccess1">Input with success</label> <input type="text" class="form-co ...

Utilize Jquery to toggle text input forms based on radio button selections

I have a group of text inputs labeled with the class 'bankinput'. Alongside them, I have two radio buttons generated by asp.net helpers. The ids assigned to these radio buttons in the generated html are 'Cheque' and 'Draft'. F ...

Tips for aligning buttons in the center of a card both vertically and horizontally

I am currently utilizing the following bootstrap template to develop a Help Desk Ticket App: After the user logs in on the index page, there are two cards available for the user to choose between heading to the app's dashboard or creating a ticket. I ...

What is the best way to connect a CSS file with multiple pages located within a specific folder in HTML/CSS?

In my CS 205 class project, I am tasked with creating a website. To accomplish this, I used Notepad++ for the HTML files and Notepad for the CSS files. The site consists of an index.html page along with other content pages, each designed separately in Note ...

Is there a way to dynamically set the width in CSS based on the width of characters used?

The value of rem is based on font height. Therefore, when setting width in rem for layout or media query purposes, it is determined by the height of the characters, not the width. I believe this may not be ideal for creating layouts. ...

Hide the div once it goes off screen, ensuring that the user stays in the same position on the page

On my website, I implemented an effect similar to the Airbnb homepage where there is a "How it Works" button that toggles a Div element pushing down the entire page. However, when the user scrolls to the bottom of the toggled div (#slideDown) and it disapp ...

Chrome does not recognize the 'position: fixed' style attribute

Encountered an issue in Chrome where the position:fixed property does not behave as expected. While this code works fine in Firefox and Safari, it seems to have a glitch in Chrome (69.0.3497.100). When scrolling, the blue div moves and reveals the green ba ...

What is the most efficient way to define the font properties for all H1-H6 headings in a single declaration

Is there a way to set all font properties for H1-H6 headings in one CSS declaration? CSSLint.net is flagging multiple definitions of heading styles as an issue. I currently have specific styles for each heading level: h1 { font-size: 1.8em; margin-top: ...

Steps for dynamically adjusting form fields depending on radio button selection

I am looking to create a dynamic form that changes based on the selection of radio buttons. The form includes textfields Field A, Field B, ..., Field G, along with radio buttons Radio 1 and Radio 2. I need to update the form dynamically depending on which ...

What is the best way to incorporate modal window parameters into this code snippet?

JavaScript function: function loadBlockEditor(block, username) { var blockInfo = $.ajax({ url: "in/GameElement/BlockEditor.php", type: "GET", data: 'block=' + block + '&nick=' + username, dataType: "html" }); b ...

How to use a loop to alternate CSS classes in HTML?

Here is a sample code using a while loop: while($fetch = $stm->fetchAll()) { echo '<tr class=""'>; echo '<td>' . $fetch['name'] . '</td>'; echo '</tr>'; } I want to ...

Adjust the position of the remaining li elements to accommodate the increased height of a single li element

I am currently working on a dropdown menu and I'm encountering an issue where, in the second level of <ul>, if the height of an <li> increases due to accommodating another <ul>, the other <li> elements in the second level do no ...

Issue with white spaces in footer content in Chrome browser

Currently in the process of developing a website and encountering a strange bug that only seems to be affecting Chrome. Despite having the latest version of Chrome, it appears to be an issue that was prevalent in older versions (v18 - v20). The problem is ...

Display information from Node.js on an HTML page

I am working on a nodejs project where I need to login on one page and display the result on another page using expressjs. Below is my code for login.ejs: <!DOCTYPE html> <html lang="en" dir="ltr"> <body> <form method="PO ...

The header that sticks on scroll is annoyingly blocking the content

I managed to create a sticky on-scroll header/navigation bar successfully. Here is how it looks now However, I encountered an issue. When it reaches the top, it automatically 'covers' the top part of my content, which has text on it, and I don& ...