Utilizing "beneath the scroll" on a bootstrap 5.1 webpage

I have a website built with Bootstrap and I am looking to implement a "below the flow" positioning for the footer, preferably using CSS. I have been referring to it as "below the fold," although I'm not sure if that is the correct terminology to use.

My goal is to have the top of the footer initially visible at the bottom of the page, giving users a hint about the existence of the footer. As the user scrolls down, the full footer will be revealed.

It is important that this functionality works on mobile devices as well.

I have searched online but have not found a solution, possibly because I am using the wrong term.

Below is a wireframe illustrating what I am trying to achieve:

Here is a code snippet that is close to what I want, but it does not display a preview of the footer:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <title>Below the Fold</title>
    <link href="https://cdn.example.com/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://cdn.example.com/js/bootstrap.bundle.min.js"
            integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
            crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.example.com/font/bootstrap-icons.css">
</head>
<body>
<main>

    <section>
        <div class="container">
            <div class="d-flex flex-column min-vh-100 justify-content-center align-items-center">
                <div class="text-center">
                    <form action="/search">
                        <div class="row mt-10 gx-0">
                            <div class="col pe-0">
                                <div class="form-group">
                                    <label class="visually-hidden" for="categories">Categories:</label>
                                    <select class="form-select" id="categories">
                                        <option selected>Category 1</option>
                                        <option disabled>Category 2 - coming soon</option>
                                        <option disabled>Category 3 - coming soon</option>
                                    </select>
                                </div>

                            </div>
                            <div class="col-12 col-sm-7 col-md-8 col-lg-9 ps-0">
                                <div class="input-group input-group-merge">
                                    <input
                                            id="query"
                                            name="cards[query]"
                                            type="text"
                                            autocorrect="off"
                                            autocapitalize="off"
                                            autocomplete="false"
                                            spellcheck="false"
                                            required="true"
                                            maxlength="512"
                                            aria-label="Search"
                                            placeholder="Search here ...."
                                            class="form-control"
                                    />
                                    <div class="input-group-append">
                                        <button class="btn btn-outline-border text-body" type="submit" title="Search">
                                            <i class="bi bi-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>


    <footer style="background-color: black">
        <div class="container">
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
        </div>
    </footer>
</main>
</body>
</html>

Answer №1

To achieve the desired effect, simply apply a negative margin top on the footer. This is necessary because the container in the top section already occupies 100% of the viewport height.

<footer style="background-color: black; margin-top: -35px;">

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <title>Below the fold</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
            integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
            crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
</head>
<body>
<main>

    <section>
        <div class="container">
            <div class="d-flex flex-column min-vh-100 justify-content-center align-items-center>
                <div class="text-center">
                    <form action="/search">
                        <div class="row mt-10 gx-0>
                            <div class="col pe-0">
                                <div class="form-group">
                                    <label class="visually-hidden" for="categories">Categories:</label>
                                    <select class="form-select" id="categories">
                                        <option selected>Category 1</option>
                                        <option disabled>Category 2 - coming soon</option>
                                        <option disabled>Category 3 - coming soon</option>
                                    </select>
                                </div>

                            </div>
                            <div class="col-12 col-sm-7 col-md-8 col-lg-9 ps-0>
                                <div class="input-group input-group-merge>
                                    <input
                                            id="query"
                                            name="cards[query]"
                                            type="text"
                                            autocorrect="off"
                                            autocapitalize="off"
                                            autocomplete="false"
                                            spellcheck="false"
                                            required="true"
                                            maxlength="512"
                                            aria-label="Search"
                                            placeholder="Search here ...."
                                            class="form-control"
                                    />
                                    <div class="input-group-append">
                                        <button class="btn btn-outline-border text-body" type="submit" title="Search">
                                            <i class="bi bi-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>


    <footer style="background-color: black; margin-top: -35px;">
        <div class="container">
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
            <div>
                Bla
            </div>
        </div>
    </footer>
</main>
</body>
</html>

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

What is the best way to differentiate between words enclosed in quotation marks using colors?

Working on my shop, I've added a section for "Colors available", but now I want to color different words with different colors using Javascript, CSS, or HTML. <button onclick="getColors()">Colors Available</button> <script> ...

Why isn't my AJAX POST request to PHP functioning correctly?

It was all working perfectly fine earlier, but now something seems off and I must have made a mistake somewhere. I'm in the process of setting up a form where the information entered is sent via AJAX to my PHP file, which then outputs the username an ...

What is the reason my hyperlinks are not clickable?

I'm working on a project that checks if a Twitchtv user is live streaming and provides a link to their page. The streaming part is working correctly, but I'm having trouble making the username clickable. Even though the URL is valid and the page ...

JavaScript and the importance of using commas in arrays

I am developing a system that displays text in a textarea when a checkbox is checked and removes the text when the checkbox is unchecked. The functionality is mostly working as intended, but I am facing an issue where commas remain in the textarea after un ...

Incorporating a Menu within a TableCell using Material-UI

I have a desire to incorporate Google's Material UI Menu Item inside a TableCell, following their documentation guidelines here in this illustration: https://i.stack.imgur.com/IffEM.png This is my current method: import React from 'react' ...

The scroll bar remains hidden even though there are additional elements waiting to be displayed

I am currently utilizing asp.net along with entity framework 4 On my page, I have three tabs structured like this: The Challenge I'm Facing The issue I am encountering is that the browser fails to display a scrollbar even when there are over 150 ro ...

Displaying the result of a JavaScript function in a textarea

I've been working on getting this function to output to the textarea below. The current code functions correctly, but it displays the output on the whole page instead of in a text field. I know that the connection between the two is not properly estab ...

Does adding the Angular bootstrap script at the end of the body tag impact webpage speed more than using ng-app on the body tag?

In the past, we had placed ng-app on the body tag which led to problems with dependency injection when multiple modules were being used on the same webpage. This required module creators to be aware of the existing app and inject their app into it. We are ...

html carousel not updating in popover

I've been attempting to create a popover with a bootstrap carousel, where the carousel items are dynamically generated and appended from a script. Despite my efforts, I have successfully displayed the carousel but struggle to append the items. I' ...

The method for retrieving and entering a user's phone number into a text field upon their visit

Objective: To enhance the user experience by automatically filling in the phone number input field when a mobile user views the page, making it easier to convert them into leads. A privacy policy will, of course, be in place. This page will offer a promo ...

Does the webworker function as a multi-thread?

For example: worker.postMessage(data1); worker.postMessage(data2); If there are multiple issues to be dealt with inside the web worker, would worker.postMessage(data2) block before completing data1? ...

Instructions on how to export an HTML table to Excel or PDF by including specific buttons using PHP or JavaScript

I created a table to display leave details of employees with sorting options from date to date. Now, I need to include buttons for exporting the data to Excel and PDF formats. Check out the code below: <form name="filter" method="POST"> <in ...

The tooltip being displayed is plain and lacks any design elements

When I hover over my a element, only a simple tooltip appears without any styling, unlike what is shown in the Bootstrap documentation. (I am creating the a element using JavaScript) HTML <!DOCTYPE html> <html lang="en"> <head> ...

Unable to see background image inside div

Why is the background image not showing up in the left column? I've applied the CSS background-image to .left but it's still not working. Any suggestions on what might be causing this issue? It seems like a small problem, but it's really bot ...

Is there a way to adjust the positioning of an image within a <div> element?

I'm attempting to vertically align an image within a horizontal menu bar. My goal is to adjust the padding/margin of the image using inline CSS. However, I've noticed that when I add margin-top or padding-top, it affects the positioning of all m ...

Updating the value of a localStorage key after each successful AJAX call in JavaScript

I'm currently facing a challenge with my local storage key value. The issue is that it doesn't update the value when the AJAX call successfully returns data. It only retains the old stored data, requiring me to manually refresh the page by pressi ...

Generate a Selectpicker dynamically when a button is clicked

Wanting to insert a new row in an HTML table dynamically by clicking on an add button. The new row includes a select element with the selectpicker class. Interestingly, when I remove the selectpicker class in my script to append a new row, the select eleme ...

The Bootstrap table fails to display any data retrieved from the server

I recently attempted to implement pagination using this resource: After setting up the HTML table on my page and confirming that the server-side code is functioning properly by checking the Network tab in the F12 tools, I ran into an issue. The data retur ...

Circular CSS menu

What I'm Trying to Achieve: I am interested in developing a unique radial menu that includes interactive elements, such as the central image and the surrounding sections. It is imperative that the solution is compatible across all browsers. The examp ...

Is the floating label feature in bootstrap not compatible with various form-control sizes?

The floating label feature works well with form-control, but when using form-control-lg (for example), it does not function as expected. Overall, this method will be successful. <input type="email" name="email" id="email" ...