Two sections each occupying 50% of the space

Working on an HTML newsletter and looking to create two divs that each take up 50% of the page, one on the left and one on the right.

Struggling with floats and tabs, none seem to be doing the trick. Any suggestions?

Appreciate any help! Thank you <3

Here's my code :)

#yellow {
        height: 100%;
        display: flex;
        flex-direction: column;
        background-color: rgb(214, 196, 0);
        order: 2;
        width: 100%;
    }

    #yellowL {
        position: relative;
        float: left;
        width: 50%;
        margin: auto;
        order: 1;
    }

    #yellowR {
        position: relative;
        float: right;
        width: 50%;
        margin: auto;
        order: 2;
    }

and here's my HTML :)

<body id="NewsletterPRONA">
<div id="news">
    <h1>News</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus dictum, urna nec vulputate molestie, neque leo ultricies mi, ut dignissim magna magna vitae ex. Nunc eu massa purus. Vivamus velit lacus, vulputate a neque ut, faucibus tincidunt elit. Sed volutpat, nunc quis vulputate sagittis, ipsum metus elementum enim, sed ornare velit elit ac nibh.</p>
</div>
<div id="yellow">
    <h1 id="h1v2">Geschäftsverlauf / Déroulement des affaires</h1>
    <div id="yellowL">
        <h1 id="h1v2">Offerten</h1>
        <p>

        </p>
        <h1 id="h1v2">Projekte</h1>
        <p>

        </p>
    </div>
    <div id="yellowR">
        <h1 id="h1v2">Offres</h1>
        <h2>Bruit</h2>
        <p>

        </p>
        <h2>Sols</h2>
        <p>

        </p>
        <h2>Déchets</h2>
        <p>

        </p>
        <h2>EIE</h2>
        <p>

        </p>
        <h2>Physique et acoustique du bâtiment</h2>
        <p>

        </p>
        <h1 id="h1v2">Projets</h1>
        <h2>Bruit</h2>
        <p>

        </p>
    </div>
</div>

Answer №1

Check out this DEMO

Make some modifications to the CSS:

#yellow {
        height: 100%;
        background-color: rgb(214, 196, 0);
        order: 2;
        width: 100%;
    }

    #yellowL {
        float: left;
        width: 50%;
        margin: auto;
        order: 1;
    }

    #yellowR {
        position: relative;
        float: right;
        width: 50%;
        margin: auto;
        order: 2;
    }

Answer №2

By applying the float:left property to both div elements, they will align next to each other.

HTML

<div class="container"></div>
<div class="container"></div>

CSS

.container{
    margin:0;
    width:50%;
    float:left;
}

Answer №3

The most effective format for newsletters is utilizing a table layout.
While it may not be the ideal solution, it does offer the highest level of compatibility across different platforms.

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

PHPMailer encountered a syntax error while processing the command 'composer install'

Attempting to implement PHPMailer on GoDaddy for the first time, encountering an error message; Parse error: syntax error, unexpected 'install' (T_STRING); when trying to run composer install. I've searched through other resources and tinker ...

Unable to view form data post submission in Laravel PHP

I have a form for submitting data, and after submission, the user is taken to another page where the submitted data is displayed. Some of my HTML structure: <form id="" method="POST" enctype="multipart/form-data" action="{{ route('r ...

The navigation drawer is revealed when you drag down other elements on the webpage

When the navigation drawer opens, it pulls down other web blocks. When it closes, the blocks come up. Additionally, the drawer menu has occupied more space on the top of my website, making it difficult to keep blocks near the navigation bar. There is a lar ...

Struggling with my HTML table styling

I attempted to construct the table below using two tables side by side, each with a width of 300, but due to the layout, when I attempt to create it as one table (which is my goal), the heights on the left and right become jumbled up because the cells on t ...

The page is displaying a horizontal scrolling bar when utilizing bootstrap framework

Currently, I am in the process of designing a webpage that utilizes Bootstrap. To structure my page layout, I am utilizing the grid system and the col-lg-x class. Specifically, I have split the page into two sections with the code below: <div class=&ap ...

Leveraging Bootstrap 5 to Ensure Consistent Image Heights in Carousels

Currently, I am developing a carousel using Bootstrap 5 and I want all images to have a consistent size regardless of their original dimensions. Here is the current state of the carousel: https://i.sstatic.net/TFVdy.png My goal is for the next image in ...

Adjust the color of the text as it scrolls by

As I work on developing my website using the Neve Theme on WordPress, I have encountered an issue with customizing the header block. I am using a plugin to set a background color for the header after scrolling 100px down the page, but this makes the text h ...

Searching for a way to sort out role-specific usernames in a dropdown menu using AngularJS?

Is there a way to effectively filter usernames based on specific roles in a dropdown using AngularJS? Hello, I am trying to filter the usernames with the 'KP' role in the dropdown list. Please refer to My plunker for more information. Init ...

Saving the content of a div as a PDF

There are several aspects to consider when it comes to this question, but I'm having trouble finding the information I need. Hopefully someone can provide an answer. Essentially, what I want to achieve is: Imagine a div that is 400 X 400 px in size. ...

Load images in advance using the link tag to eliminate the warning (html/Javascript)

After attempting to insert <link rel="preload" as="image" href="path"> into the <head>, I received a warning in the console. {path to image} was preloaded using link preload but not used within a few seconds from t ...

Tips for overlapping children in a column flex direction while maintaining the parents' positioning

Currently, I am working with two parent flex items, arranged with flex-direction: column. Within the first parent, there are two children. However, one of the children is optional and may be removed at times. I aim to have the optional child displayed on ...

Unexpected behavior observed when trying to smoothly scroll to internal links within a div, indicating a potential problem related to CSS dimensions and

Within a series of nested div containers, I have one with the CSS property overflow:hidden. My goal is to smoothly scroll to internal links within this specific div using jQuery. The snippet of code below has worked successfully in previous projects: ...

Is there a way to identify the specific Struts action being rendered in my JSP file?

One thing I am struggling with is creating a menu that highlights the current page when navigating through my site. For example, if I am on Page 1, I want the "Page 1" link in the menu to stand out. I have been attempting different methods found on Stack O ...

Using various colors to highlight specific sections of a letter or number

I am striving to recreate the unique image shown below, particularly interested in achieving the multi-colored effect on the numbers. This aspect of having different colors for parts of the number is intriguing and I would love to learn how it's done. ...

Tips for retrieving data from an Excel spreadsheet on an HTML/CSS webpage

I have a single HTML template at this location: . The current page is tailored for the state of Arkansas in the US, but I now need to replicate the design for all 50 states. Each state page will have the same layout, but different content specific to that ...

HTML elements have a delayed rendering process in ReactJS

As I dive into learning ReactJS by creating a ReactJS version of my blog, I encountered an interesting issue while testing Google Page Speed. The recommendation to "prioritize visible content" led me to add a placeholder article with a loading message, lor ...

Utilizing jQuery time intervals within a jQuery click event: A step-by-step guide

For my dropdown menu project, I am facing an issue where the menu bar is not reappearing after collapsing the dropdown. It seems that the jQuery function responsible for toggling classes within a time interval is not executing properly. Specifically, the " ...

Attempting to alter an image with a click and then revert it back to its original state

I'm currently working on a feature that toggles an image when a specific class is clicked. The code I have so far successfully switches from 'plus.png' to 'minus.png' upon clicking, but I need it to switch back to 'plus.png&ap ...

Utilize the mailto function in HTML to dispatch an email

I am utilizing an Android hybrid app that includes a link for sending emails: <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcafb4aeb5b7bdb2a8b6bdb8b4bdaae4ea9cbbb1bdb5b0f2bfb3b1">[email protected]& ...

Issues with aligning text in a flexbox using Bootstrap 4's text-center property

I am currently working on a project to create a webpage with two vertical columns that are clickable and lead to different pages. Here is what I have so far. HTML <!-- Choices --> <div class="container-fluid"> <div class="row"> ...