What's causing my button to line up horizontally within a flexbox that is positioned vertically?

My button is aligned within the flex-box, shouldn't the elements be stacked in a column?

I am working on a timer that features a row with two columns.

One column contains an image while the other consists of a heading, a flexbox with four rectangles, and a button.

However, I want the button to be positioned below the timer but it is currently aligned with it.

HTML


        <!DOCTYPE html>
        <html lang="en">
        
        <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Stiks</title>
            <link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
            <link rel="stylesheet" href="../css/style.css">
            <link rel="preconnect" href="https://fonts.gstatic.com">
            <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
        </head>
        
        <body>
            <div class="container hero">
                <div class="row">
                    <div class="portal col-md-12 col-lg-5">
                        <img class="img-fluid" src="../assets/download (10).jpg">
                    </div>
        
                    <div class="col-md-12 col-lg-7 align-self-center">
        
                        <h2><b>Timer</b></h2>
        
                        <div class="d-inline-flex flex-nowrap">
                            <div class="rect">
                                <span class="days"></span>
                                <p>Days</p>
                            </div>
        
                            <div class="rect">
                                <span class="hours"></span>
                                <p>Hours</p>
                            </div>
        
                            <div class="rect">
                                <span class="minutes"></span>
                                <p>Minutes</p>
                            </div>
        
                            <div class="rect">
                                <span class="seconds"></span>
                                <p>Seconds</p>
                            </div>
                        </div>
        
                        <button class="btn-main" type="button">Start</button>
        
                    </div>
        
                </div>
            </div>
        
        </body>
        </html>
    

CSS


        :root{
            --yellow: #fff189;
            /* Add more variables here */
          }
          
          h1{
              font-size: 4.2em;
          }
          
          h2{
              font-size: 1.75em;
          }
          
          /* More CSS styles can be added here */
    

Answer №2

I conducted a test on your code and found that as the browser's width changes, the layout shifts to inline or below the boxes at times.

To resolve this issue, you can include the following code snippet:

Add display: block; in your .btn-main class as shown below:

.btn-main{
display:block;
}

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 fixed header column doesn't remain sticky

I am working on fixing the first column in my table to remain static on mobile devices so that users can easily identify the data they are viewing when scrolling. While the td elements in the table work perfectly as intended, the column header continues to ...

What is the process for extracting data from a canvas tag and why does it appear invisible on my browser?

The highlighted area in this image contains the HTML content and the red circle marks the section to be scraped The phone number can be found within the canvas tag. However, when trying to scrape the tag, it shows "Your browser does not support the HTML5 c ...

Unsuccessful CORS on whateverorigin.org with YQL

Despite trying all three methods, I keep getting an error regarding cross domain access denied. Previously, I had successfully used YQL in different parts of my applications, but now it seems to have stopped working as well. JSFIDDLE <script> $(fun ...

Enhance PHP search functionality by showcasing hidden auto-complete suggestions in real-time

I am attempting to showcase unlisted search results that can be clicked on to redirect the user to a specific HTML page based on data retrieved from a MySQL database. My development environment is PhoneGap. Thus far, I have successfully set up a basic PH ...

Ways to determine if content is visible within a div

My website contains a script that brings in content from an ad network and displays it within a div element. Unfortunately, this particular ad network only fills ads 80% of the time, leaving the remaining 20% of the time without any ads to display. This la ...

What is the best way to search for a CSS selector that includes an attribute beginning with the symbol '@'?

Whenever I want to target an element with a click event, I usually use the following jQuery selector: $('div[@click="login()"]') <div @click="login()"> Login </div> However, when I tried this approach, it resulted ...

Is it possible to protect passwords internally via URL and AJAX?

During my time at a previous company, we had an internal website that required a password to be entered at the end of the URL in order to view it. I suspect this was done using AJAX, but I am unsure. Even if AJAX was used, I do not know how to code it myse ...

JavaScript can be used to target and remove parent <tr> elements that contain empty <td> elements with a specific class

I am facing a challenge with a large HTML table that is populated by variables set in JavaScript from my database response. When the database returns an empty string, I want to remove the entire parent row using JavaScript. Although I have attempted to us ...

Issue: Unable to locate a change supporting element '[object Object]' of the type 'object - Angular 7'

An angular service has been created for the specified purpose: CheckTicket(barcode, codEspec, diaHoraEspec):Observable<Ticket[]>{ //read ticket return this.http.get<Ticket[]>(`${this.checkticket_url}${barcode}?token=${this.token}&a ...

Retrieving a page using jQuery

Below is the JavaScript code that I am using: $.ajax({ url: "test.html", error: function(){ //handle error }, success: function(){ //perform actions here with the received data } }); After retrieving test.html, I am wo ...

Is there a way to modify the background color of ::before when hovering over it?

I have a ul-li list and when i hover last li ::before element looks white and not so good. I want to change it when i hover the last li element. How can I achieve this? Here are my codes: <div className="dropup-content"> <ul> & ...

When the page is scrolled to 50 pixels, a modal pop-up will appear

I attempted to use cookies to store a value when the user clicks on a popup to close it, ensuring that the popup does not show again once closed. However, I am encountering an issue where the popup continues to open whenever I scroll, even after closing it ...

Arranging multiple lines of text above several images using CSS

I'm encountering issues when trying to place multiple texts in front of multiple images. I've managed to achieve this using absolute and relative positioning, with one text above one image. However, the problem arises when I try to apply this to ...

iOS emphasizes special characters by printing them in bold

Some parts of the website I am managing are showing German umlauts in bold (as seen in the screenshot). The font style being used is font-family: Source Sans Pro, Arial, sans-serif; with font-weight: 300. This font is sourced from Google Fonts. When I cha ...

How to retrieve the selected text from a specific <span> using JavaScript

Is there a way to extract only the selected text from a specific span element? <span style="font-size:40px">Hi tTheee</span> <span style="font-size:20px">hello</span> <span style="font-size:20px">sdsds </span> Current ...

The customized Vaadin component with a tag is missing from the MainView layout

I am attempting to integrate my custom vis component into the MainView VerticalLayout. However, it is appearing above the layout and the layout itself contains an empty component tag. Custom component code In this section, I have labeled my component as " ...

Integrate a button following the first paragraph exclusively when there are two or more paragraphs present

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> jQuery(document).ready(function($) { if ( $('p').length < 1 ) { $('p:last-child').after('<div id="toggle" class="btn"> ...

Is that possible to prevent the use of the & symbol in Angular 4 HTTP requests?

Using an HTTP request to save data in my database. The code snippet I used is: const form = '&inputdata=' + myinput + '&rf_date=' + rf_date; return this.http.post(this.rootUrl, form, {headers : this.reqHeader}); In thi ...

Issue with 'backface-visibility' CSS3 property not functioning on any versions of Internet Explorer

I'm looking to implement a specific animation in Internet Explorer. The goal is to rotate an image like a coin, displaying a different image on the other side. I suspect that the issue lies with Backface-visibility in IE, but I'm not entirely sur ...

Leveraging the power of animate.css library to enhance page transitions on Nuxt

I've been working on implementing the animate.css library for nuxt page transitions, but I'm encountering some issues. I have successfully added animate.css to the nuxt.config.js file and it loads without any problems. However, when I try to use ...