What is causing child elements to not wrap to the next line when the parent element is set to display:flex?

In order for the div with 's' class to move to the next line, it should be displayed as a block element.

Check out the code on jsfiddle here.

<body>
            <div class="header">
            <div class="header-first">
            <div>FLYWHEEL <span>▼</span></div>
            </div>
            <div class="header-second">
                <div class="one">PRODUCT <span>▼</span></div>
                <div class="s">S</div>
            
            </div>
            </div>
            </body>
            
             body{
                    background:linear-gradient(to bottom right,#3f557c,#8af3c7be,#e7800abe);
                    height:100vh;
                    padding:0px;
                    
                    
                    }
                .header{
                position: relative;
                height:20%;
                width:100%;
                margin:0px;
                
                
                }
                .header-first,.header-second{
                    position:relative;
                    float:left;
                    display:flex;
                    padding:0;
                    margin:0;
                    align-items: center;
                   justify-content: center;
                    background-color:rgb(129, 137, 173);
                    border-radius:30px;
                    box-sizing:border-box;
                    height:100%;
                    width:11.11%;
                    font-family: Comic Sans MS, Comic Sans;
                    color:rgba(255, 166, 0, 0.904);
                    font-size:16px;
                    
                   }
                   .s{
                   
                     border:3px solid red;
                   }

It seems that the issue with the 's' class not moving to the next line could be related to the parent element's display property being set as a block element. Could this have something to do with display:flex or float:left?

Appreciate any insight!

Answer №1

By changing the display property to flex, the default flex-direction is set to row. If you specify flex-direction: column, the child elements will be displayed in a single column underneath each other.

To learn more about flex-direction, visit MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction

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

Bringing together embedded chat and stream seamlessly with CSS styling

I'm in the process of integrating a chat feature with my Twitch stream on a Xenforo forum page. I aim for the stream to be displayed in 16:9 aspect ratio to ensure high definition quality, and I want it to adapt to the user's screen resolution. B ...

What are some effective strategies for avoiding empty fields showing on an email form?

My HTML form is linked to a PHP Email handler, and it's working well except for one issue. When the email is delivered, it includes all fields, even the empty ones. I want it to only display filled-in fields. I tried using an IF statement that checks ...

Extracting the submit input value with jQuery while implementing AJAX on a form

Imagine you come across this code snippet: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title><!-- Put your title here --></title> <s ...

When tested, the code compiles successfully; however, errors arise upon submission

Is there a way to fix the issue with submitting code through a custom parser where all script functions return "Missing or in the wrong place." errors? Interestingly, when testing the same code on platforms like JSFiddle, it parses correctly. I'm uns ...

A stylish Bootstrap list group featuring large Font Awesome icons

I am working with a Bootstrap 5 List Group element on my webpage. To enhance its visual appeal, I want to include oversized Font Awesome icons. After some styling and using a span tag, I managed to add the icon successfully. However, the issue I am facing ...

Converting Data from MySQL and PHP to Excel

Is there a way to export human resource applications stored in my MySQL table as an Excel file? function exportExcel($filename='ExportExcel',$columns=array(),$data=array(),$replaceDotCol=array()){ global $connect; header('Content-Enc ...

On the upper right corner, you'll find a dropdown feature that, when clicked, displays a list of items on

Problem Description The dropdown menu appears on the top right side and displays items on the top left side when clicked. How to reproduce? To replicate the issue, please ensure that the window is maximized. Steps Taken So Far: Link to JS Fiddle Code ...

Steps to indicate a selected check column in a grid

I am working with a grid that has a check column, and I need to programmatically mark the checkbox. This is how the check column is coded: columns: { items:[ { itemId: 'checkColumn', xtype: 'selectallche ...

Error in linking PHP code to display stored tweets using HTML code

![enter image description here][1]![image of output of twitter_display.php][2] //htmlsearch.html file <!doctype html> <html> <head> <title>Twitter</title> <meta charset="utf-8"> <script> window.onload = function ...

Having trouble capturing a photo from webcam using HTML5 and getUserMedia() in Google Chrome upon initial page load

Using the information from an article on HTML5Rocks, I am attempting to create a tool that can capture photos from a webcam. Here is an excerpt of my HTML code: <button type="button" name="btnCapture" id="btnCapture">Start camera</button>< ...

Swap image in div upon hovering over a list of links in another div

I'm in the process of designing a webpage that features a header and footer fixed to the top and bottom of the browser window, with adaptable content in between. To structure the inner content, I've opted for a flexbox wrapper containing a list o ...

What is the best way to showcase images from a local directory in an HTML div element?

I have a few JPEG images located in the directory "C:/images/". I want to create a slideshow of these images on a webpage. I am using Java code to retrieve the correct path of the image folder and JSP as the front end with an HTML div element to display th ...

The page is present, but unfortunately, the content is displaying a 404 error. I am considering using Selenium to retrieve

Is there a way to use Selenium webdriver to download images from a dynamically updated website, like this site? Every day a new page is created with images uploaded around 6 pm. How can I retrieve these images using Python and Selenium? url = 'http:/ ...

"The functionality of the express post method does not seem to be working properly when accessing

I am having trouble retrieving form data sent using the "POST" method from an HTML form in my app.post method. I am unable to access anything from req.body. Can anyone point out what mistake I might be making? Here is my HTML form - <form method=" ...

How can I arrange an array of strings with dates in C# or use ordering functionality in AngularJS?

I've got an array of dates in the following format: string[] arr=["08.02.2017","09.02.2017","30.01.2017","31.01.2017"] What is the most efficient method to sort this array in C# so that the order is descending? I want the data to be displayed within ...

The element is failing to wrap correctly, as it appears incorrectly when the viewport is resized and scrolled to the right

Through experimentation with the most basic HTML setup, I made a startling discovery. It seems that the wrapping of the top <html> tag is malfunctioning in EVERY browser. In my setup, I have applied a yellow background color to the <html> elem ...

The issue of margin error and vertical alignment on pseudo-elements

Here's the HTML code I am working with: <article> <picture> <img src="a.png"> </picture> </article This particular HTML code is used throughout my page, where the image has a varying width. The goal is to c ...

Tips for renaming input file before uploading to a new destination

Instead of using the original name, I would like to replace the image that the user wants to upload with my own pattern. I understand that it's preferable to change the file name on the server, but unfortunately, I am unable to do so for certain reaso ...

Fixed position does not adjust based on the screen resolution

If I were to create a web page, I would include a main menu that always remains on the screen, similar to this design: https://i.sstatic.net/I57Xk.png There are no issues with screen resolution exceeding 1300px, as seen in the image above. However, when ...

How to create HTML buttons with CSS that maintain proper proportions?

How can I ensure that my HTML buttons adjust proportionally to different screen sizes? I've been working on coding an Android app using HTML and CSS, and everything seems to be running smoothly. However, when I share the file with a friend, he compla ...