Flex wrap in div isn't functioning properly, causing elements to overlap instead of wrap

I am struggling with a section containing two main divs:

<section class="about-us" id="about-us">
            <div class="abtus-img">
                <img src="/images/about-us.jpeg" alt="Patricia and Midel">
            </div>
            <div class="content">

                <div class="abtus-text">
                    <h3>Today is God's</h3>
                    <h3>Unfailing faithfulness</h3>
                    <h3>WE</h3>
                </div>
    
                <div class="main-text">
                    <h1>Name</h1>
                    <p>and</p>
                    <h1>Name</h1>
                </div>

                <div class="info">
                    <div class="info-p">
                        <p>Invite you to share the beginning of our new life together as we unite and make our blessed commitment to God and to each other in Holy Sacrament of Matrimony
                        </p>
                    </div>
                    <div class="main-info">
            
                    </div>
                </div>
            </div>
        </section>

Any suggestions on why the child divs are overlapping instead of wrapping? I have tried adjusting their width, removing flex gap, and increasing size but the issue persists. [Styling Sheet]

Even after decreasing width and eliminating flex gap, the child divs do not wrap when resizing the window, they just overlap.

main .about-us {
    display: flex;
    width:90%;
    height:70vh;
    border-bottom: 2px solid black;
    margin-bottom: 2em;
    flex-wrap: wrap;
}

main .about-us .abtus-img {
    width:60%;
    border-right: 1px solid black;
    display: flex;
    justify-content: center;
    align-self: center;
}

main .about-us .abtus-img img {
    height:40em;
    width:30em;

}

main .about-us .content {
    width:40%;
    height:50%;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 2em;
    justify-content: space-evenly;


}

main .about-us .content .main-info {
    width:60%;
    margin-top: 2em;
}
main .about-us .content .info {
    margin-top: 1em;
}

main .about-us .content .main-text {
    margin-top: 2em;
    line-height:3.5em;
}
main .about-us .content .main-text h1 {
    text-transform: uppercase;
    letter-spacing: 4px;
    font-size: 2.2em;

}

main .about-us .content .main-text p{
    font-family: 'Dancing Script', cursive;
    font-size: 1.3em;
}

Answer №1

The parent flexbox container .about-us has a specific height defined as 70vh, but it is not enough to accommodate the two child elements properly. Although the children are wrapping, they are also attempting to squeeze into the limited space of the parent element.

Answer №2

It seems that there was a discrepancy in the use of the "main" tag in your CSS file without actually having the corresponding tag in your HTML code. By removing the "main" from the CSS, everything started working correctly:

.about-us {
    display: flex;
    border-bottom: 2px solid black;
    margin-bottom: 2em;
    flex-wrap: wrap;
}



.about-us .abtus-img img {
    height:100%;
    width:100%;

}

.about-us .content {
    width:40%;
    height:50%;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 2em;
    justify-content: space-evenly;


}

.about-us .content .main-info {
    width:60%;
    margin-top: 2em;
}
.about-us .content .info {
    margin-top: 1em;
}

.about-us .content .main-text {
    margin-top: 2em;
    line-height:3.5em;
}
.about-us .content .main-text h1 {
    text-transform: uppercase;
    letter-spacing: 4px;
    font-size: 2.2em;

}

.about-us .content .main-text p{
    font-family: 'Dancing Script', cursive;
    font-size: 1.3em;
}
<section class="about-us" id="about-us">
            <div class="abtus-img">
                <img src="https://assets.codepen.io/t-1/user-default-avatar.jpg?format=auto&version=0&width=80&height=80" alt="Patricia and Midel">
            </div>
            <div class="content">

                <div class="abtus-text">
                    <h3>Today is God's</h3>
                    <h3>Unfailing faithfulness</h3>
                    <h3>WE</h3>
                </div>
    
                <div class="main-text">
                    <h1>Name</h1>
                    <p>and</p>
                    <h1>Name</h1>
                </div>

                <div class="info">
                    <div class="info-p">
                        <p>Invite you to share the beginning of our new life together as we unite and make our blessed commitment to God and to each other in Holy Sacrament of Matrimony
                        </p>
                    </div>
                    <div class="main-info">
            
                    </div>
                </div>
            </div>
        </section>

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

overflow with a height of 100%

I want to add vertical scroll bars to my left and right columns without setting the height to 100%. How can I achieve this scrolling effect without specifying height: 100%? html,body{height:100%;} .row > .sidebar-fixed { position: relative; to ...

What is the best way to incorporate Skeleton.css into my React application?

As someone who primarily uses React in React Native but is now working on a website, I have run into some issues trying to implement skeleton.css in my React App. <!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> ...

Is HTML unable to display decoded %3C?

Two blocks of code with different input strings yield different results: // This does not change HTML var str = "%3Cdiv%3E"; // <div> var str_dec = decodeURIComponent(str); console.log(str_dec); // Console output is `<div>` document.getEleme ...

Is it possible for audio to be activated and played while the phone is locked?

I am currently developing a web chat application and I have encountered an issue regarding playing notification sounds when a new message arrives. Initially, I decided to utilize howler.js for playing the sounds. While howler allows us to start playing a ...

Encountering issues with Html.ActionLink in Asp.net MVC when using Bootstrap Select

I am trying to implement a dropdown list for language localization on my website. However, when using <ul> tags with Html.ActionLink, the links are created with language codes as shown below: @{ var routeValues = this.ViewContext.RouteData.Valu ...

Creating a Table with HTML and CSS

I am struggling to include a column span paragraph in my table and then display the actual table values below it You can see what I am attempting to achieve in this image https://i.sstatic.net/VpmTH.png <table> <thead> ...

Add some hues to the icons

I am a beginner when it comes to CSS and jQuery. My goal is to color in an icon, similar to Instagram's heart icon which turns red when double-tapped. Currently, I am using Font Awesome for this purpose. However, I am struggling to fill the color as ...

The Bootstrap floating label feature is causing a conflict with the jQuery validation labels

I'm currently utilizing the floating label code snippet from Bootstrap 5 documentation, along with jQuery validation. However, I'm experiencing conflicts with both labels when the error message is displayed. Here are some screenshots showcasing ...

When trying to include an external class that extends Pane in a main class in JavaFX, simply adding it may not achieve the

My primary class is as follows: public class Digital_Analog_Clock_Beta_1 extends Application { @Override public void start(Stage primaryStage) { double outerBoxWidth = 500, outerBoxHeight = outerBoxWidth / 2.5; Rectangle outerB ...

Showing the values of two distinct select boxes in a URL

Here are both select boxes, the goal is to display selected values from both in the URL. This can be achieved by displaying them like this: e.g www.example.com#135+#140 OR www.example.com#135&140 (The order of values doesn't matter as long as bot ...

Why does my contact form display PHP code unexpectedly?

I've been following a YouTube tutorial to create a responsive single-page website using Bootstrap. The tutorial covered the front-end, but now I'm stuck on integrating a contact form. I added some PHP code I found online, but there seems to be an ...

Unable to view a basic bottle webpage on Raspberry Pi from a PC

After referencing the instructions found at , I successfully tested them on a Raspberry Pi using the following code snippet: from bottle import route, run @route('/hello') def hello(): return "Hello World!" run(host='0.0.0.0', port ...

Show search results using jQuery in a Smarty template

I am attempting to showcase a search result within a <div> on a smarty template. The search result originates from a click action. The anchor in question is as follows: <li class="price-list-item"><a href="javascript:void();" class="price" ...

Graphic aligned with textual content

Within my table cell resides text and an accompanying image icon. However, the presence of the image causes the text to shift downwards, not aligning in the center as desired: I am now seeking a solution that will allow the text to be centered within the ...

Ways to extract innerHTML content from a loaded element generated by using the .load() method

Check out the code snippet below: template.html : <div id="nav"> Welcome to Space </div> layout.html : <div id="content"> </div> $('#content').load("template.html #nav"); ale ...

Is it possible to adjust the background size using jQuery?

When attempting to set backgroundSize with jQuery using the code provided, I consistently encounter an error on the fourth line: "unexpected identifier." bigwidth = 200; bigheight = 100; $(e.target).css({backgroundImage: 'url(' + ...

Flex items refusing to wrap in Firefox

I am facing an issue with my layout setup in different browsers. When I have a list of divs inside a flex div, it displays correctly in Chrome: However, in Firefox, it only shows a horizontal scroll with one line. Is there a way to prevent the forced hor ...

Having trouble finding an element within an HTML DOM that is nested inside an object tag using Selenium

I'm currently in the process of automating tests on an HTML page using Selenium in C#. The parent/outer HTML page has an object tag, within which there is another HTML page. Here's a snippet of how the sample HTML code looks: <!DOCTYPE html&g ...

Safeguard your HTML, PHP, and image files from being monitored

What methods can be used to safeguard your files, such as PHP and image files, from being tracked by tools like TeleportPRO and HTTrack? Your time is greatly appreciated. Thank you! ...

What is the best way to apply three unique classes to multiple div elements using jQuery?

Utilizing jQuery to assign three different classes to my div elements with the same name. Here is the HTML: <div class="main-class"> <div class="myclass"></div> <div class="myclass"></div> <div class="myclass"></div& ...