Vertical alignment can be a challenge with Bootstrap flex items

I’m currently facing an issue with centering the elements within the <main> tag. There seems to be a mysterious gap between the <h1> and <h3> elements, and I can’t seem to pinpoint the root cause of this spacing anomaly. Any insights on why this gap is manifesting would be greatly appreciated! Thank you in advance.

The alignment was initially flawless, but after making adjustments to the navbar, things seem to have gone awry. Despite inspecting the page, I can’t detect anything peculiar that could explain the sudden gap between these items enclosed within the <main> element—there simply seems to be nothing visibly amiss.

<!DOCTYPE html>

<html lang="en">
    <head>
        <!-- A range of essential meta tags included here -->
        <title>{% block title %}Welcome{% endblock %}</title>
    </head>

    <body>
        <nav class="navbar navbar-light container-fluid d-flex align-items-top justify-content-start">
            <a class="navbar-brand" href="/"><img href="index.html" src="/static/ladybug.png" width="30" height="30" class="d-inline-block align-left" alt=""></a>
            <a class="navbar-brand" href="/login">Login</a>
            <a class="navbar-brand" href="/register">Register</a>
        </nav>
        {% block main %}
        <main class="container-fluid d-flex align-items-center justify-content-center h-100 w-100">
                <div class="row align-items-center h-100">
                    <h1 class="text-center col-12">Require assistance with debugging your code?</h1>
                    <section class="text-center col-12">
                        <h3 class="d-inline-flex p-2"><strong>Seek out a study buddy for speedier problem-solving</strong></h3>
                        <div>
                            <center><hr></center>
                        </div>
                        <button type="button" class="btn btn-danger">Join Us Today!</button>
                    </section>
                </div>
        </main>
        {% endblock %}

        <footer class="row footer">
            <p class="text-center col-12 ">EDX Harvard | CS50 2019 | Final Project</p>
        </footer>
    </body>
</html>

Incorporated mostly bootstrap with my custom CSS:

body,
html
{
    margin: 0;
    width: 100%;
    height: 100%;
    background: url(/static/images/girl_2.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

.navbar-brand
{
    font-family: 'Anton', sans-serif;
    font-size: 3vmin;
}

h1
{
    padding: 0px;
    font-family: 'Anton', sans-serif;
    font-size: 6vmin;
    margin: 0;
    color: #295696;
    text-shadow: 0.1vmin 0.1vmin #6f8bb3;
}

h3
{
    font-family: 'Roboto', sans-serif;
    font-size: 3vmin;
    padding: 10px;
    color: #fec345;
    background-color: #295696;
}

hr
{
    border-color: #eb3461;
    border-width: 3px;
    max-width: 90px;
    margin: 10px;
}

I’ve attached a screenshot illustrating the perplexing gap for reference:

https://i.sstatic.net/lWARG.jpg

Answer №1

<html lang="en">
    <head>
        <!-- Necessary meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <!-- Including Google fonts-->
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Anton&family=Roboto&display=swap" rel="stylesheet">
        <!-- Adding bootstrap -->
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <!-- Favicon from https://favicon.io/emoji-favicons/money-mouth-face/ -->
        <link href="/static/favicon.ico" rel="icon">
        <link href="/static/index.css" rel="stylesheet">
        <title>{% block title %}Welcome{% endblock %}</title>
    </head>

    <body>
        <nav class="navbar navbar-light container-fluid d-flex align-items-top justify-content-start">
            <a class="navbar-brand" href="/"><img href="index.html" src="/static/ladybug.png" width="30" height="30" class="d-inline-block align-left" alt=""></a>
            <a class="navbar-brand" href="/login">Login</a>
            <a class="navbar-brand" href="/register">Register</a>
        </nav>
        {% block main %}
        <div class="container-fluid d-flex align-items-center justify-content-center h-100 w-100">
            <div class="row justify-content-center">
                <header class="text-center col-12">
                    <h1><strong>Seeking assistance with debugging your code?</strong></h1>
                </header>
                <section class="text-center col-12">
                    <h3 class="d-inline-flex p-2"><strong>Connect with a study partner for faster solutions</strong></h3>
                    <div>
                        <center><hr></center>
                    </div>
                    <button type="button" class="btn btn-danger">Join Us Today!</button>
                </section>
            </div>
        </div>
        {% endblock %}

        <footer class="row footer">
            <p class="text-center col-12 ">EDX Harvard | CS50 2019 | Final Project</p>
        </footer>
    </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

Identifying browser compatibility for date input type with Angular 2 and above

Is there a reliable method to check if the browser supports <input type="date"> in Angular2+? I came across a suggestion on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date where they recommend creating the input element and chec ...

Why does my 'click' event listener only work for the first two <li>'s and not the others?

I am new to programming and recently achieved success with my 'click' eventListener. When clicking on the first two li elements within the ul, the class of the div toggles on and off as expected. However, I encountered an issue where clicking on ...

FireFox appears to be experiencing issues with accessing the contentDocument of a frame using jQuery

While this line of code functions correctly on Chrome and IE, it encounters an issue on FireFox. The error message displayed in the FireFox console is: ReferenceError: $ is not defined var lang = $($('#navFrame')[0].contentDocument).find('# ...

Connecting Filters Vue.js

I am in need of chaining filters. My goal is to implement the following filters: - A search filter - A checkbox styled price filter with pre-defined values such as <$10, $20-$50, $50+ - A checkbox styled filter for selecting 'topics' ...

How can I dynamically change the orderBy parameter based on conditions in an Angular application?

I need to dynamically change the orderBy parameter in a table row based on the result of a method. Here is an example of my current tr setup - <tr class="pl" ng-repeat="thing in things | orderBy:'oldId':reverse" ng-class="{'row-error&apo ...

I plan to add new information to my table only when the user clicks on the submit button. This is what I have accomplished until now

<!DOCTYPE html> <html> <head> <title>Sign up page</title> </head> <body> <form method="get" action="signup_redirect.php"> username: <input type="text" name="username" placeholder=" ...

Display JavaScript and CSS code within an Angular application

I am working on an Angular 1.x application (using ES5) where I need to display formatted CSS and JS code for the user to copy and paste into their own HTML file. The code should include proper indentations, line-breaks, etc. Here is a sample of the code: ...

Displaying PHP values in HTML using the print format function

Hey there, I am a beginner in PHP and I'm currently working on displaying values from my SQL table within an HTML article. I have chosen to use the article structure because it fits my needs. Essentially, I want to retrieve the path and username data ...

What is the best method to transfer an array as a parameter from an Ipython notebook to an HTML file that includes specific javascript functions?

I have a unique HTML file named "file.html" that includes a distinctive JavaScript function described below: The Unique file.html <html> <head> </head> <script> function customFunction() { perform an action using ...

Inserting a singular image following a designated list item

I have a question that may seem silly, but I'm trying to understand a specific CSS styling issue. I want to add an image targeting a particular li item. Currently, the code adds the image after all the li items: .menuStyling li:after{ content: u ...

Accordion transition: successfully collapses, but struggles to expand back up

I've been working on creating an accordion that smoothly rolls down when selected and rolls back up when closed. While I've managed to get it to roll down, it simply closes without any transition when I try to close it. I attempted setting a max ...

Struggling to access your account on the Django website?

I'm having trouble creating a login page in Django. I have completed the views, HTML, and everything, but the problem is that when I try to log in, it doesn't work. After some debugging, I found that the user value is None, but I don't under ...

Pressing the tab key makes all placeholders vanish

case 'input': echo '<div class="col-md-3"> <div class="placeholder"> <img src="images/person.png" /> &l ...

display and conceal a division by clicking a hyperlink

How can I make a hidden div become visible when clicking on a specific link without using jQuery? Javascript function show() { var a = document.getElementsByTagName("a"); if (a.id == "link1") { document.getElementByID("content1").style.v ...

Perform validation on input by monitoring checkbox changes in Angular 4

I am currently working on a project where I need to loop through an array of key values in order to create a list of checkboxes, each accompanied by a disabled input field as a sibling. The requirement is that upon checking a checkbox, the corresponding in ...

When I hover over it, my play button refuses to show up

I am in the process of creating a music streaming website and I would like the play button to appear when hovering over a song. However, I am encountering an issue with the CSS section overriding the others that are meant for different parts (I am using Fo ...

AngularJS ng-submit can be configured to trigger two separate actions

I am currently diving into AngularJS and working on a simple project to create an expense tracker as a beginner task. However, I have encountered some issues with my code. While I have successfully implemented most functions, I am struggling with the upda ...

Bootstrap navigation bar unresponsive on mobile devices

<nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark"> <a class="navbar-brand" href="#">Yehee-Lounge</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav ...

Locate/place name with AngularJS and Google Maps integration

I need help locating the user-selected location on a map. I currently have the latitude and longitude, but I'm struggling to obtain the location name. My project utilizes angularJS along with angular-google-maps 2.1.5. Below is the HTML code: <u ...

Sorting of boxes is not possible when utilizing the sortable() function

Is there a way to swap the positions of the left and right boxes using the sortable() function from jQuery UI? It seems to work fine for numbers 1 and 2, but not for switching the boxes. $(".sort-me").sortable({ connectWith: ".connectedSortable" } ...