Horizontal line displayed in the jumbotron's footer

https://i.sstatic.net/9cjiD.jpg

I'm having trouble aligning two horizontal lines (hr) in my jumbotron. The first line aligns correctly at the beginning of the page, but the second line, located at the bottom of the logo, should be at the end of the page. I've set the height to 100 vh.

.jumbotron{
height: 100vh;

How can I align the second hr at the end of the page? I've tried using align-items-end, but it didn't work.

My code includes Bootstrap 4 and the HTML structure is as follows:

    <!DOCTYPE html>
<html lang="de">

<head>
    <!-- Important Meta Tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- CSS
  ============================================================================================= -->

    <!-- Bootstrap -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat|Spectral" rel="stylesheet">
    <!-- Simple Line Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.css">
    <!-- Custom -->
    <link rel="stylesheet" href="assets/css/style.css">
</head>

<body>

    <header class="hero-bg">
    <!-- Navigation -->
    <nav class="navbar navbar-expand-md navbar-dark fixed-top">
        <div class="container m-auto nav-line">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-toggle" aria-controls="navbar-toggle" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-center text-uppercase font-alt" id="navbar-toggle">
                <ul class="navbar-nav mt-1">
                    <li class="nav-item">
                        <a href="#texting" class="nav-link">Texting</a>
                    </li>
                    <li class="nav-item">
                        <a href="#eventkonzeption" class="nav-link">Event Konzeption</a>
                    </li>
                    <li class="nav-item">
                        <a href="#impression" class="nav-link">Impressionen</a>
                    </li>
                    <li class="nav-item">
                        <a href="#ueber" class="nav-link">Über mich</a>
                    </li>
                    <li class="nav-item">
                        <a href="#kontakt" class="nav-link">Kontakt</a>
                    </li>
                </ul>
                <!-- navbar-nav -->
            </div>
            <!-- navbar-collapse -->
        </div>
        <!-- container -->
    </nav>
    <!-- End Navigation -->
</header>

<!-- Header -->
<section id="home" class="hero-bg jumbotron">
    <div class="container pt-0 pb-5 header-h">
       <hr style="background: white; justify-content-start">
        <div class="align-items-start row justify-content-center">

            <div class="img-logo col align-self-start">
                <img class="img-fluid d-block img-responsive" src="resources/img/logo.png" alt="Rollywood-Logo" >
            </div>
            <!-- col -->
        </div>

        <!-- row -->
           <hr class="align-self-end" style="background: white;"> 

    </div>

    <!-- container -->
</section>
<!-- Header -->

    <!-- jQuery -->
    <script src="assets/js/jquery-3.2.1.min.js"></script>
    <!-- Popper -->
    <script src="assets/js/popper.min.js"></script>
    <!-- Bootstrap -->
    <script src="assets/js/bootstrap.min.js"></script>
    <!-- Custom -->
    <script src="assets/js/custom.js"></script>

</body>

</html>

Answer №1

If you want to maintain the <hr> elements inside the jumbotron while solving this issue, simply add the classes d-flex flex-column h-100 to the container within the jumbotron. Then, include the mt-auto class (margin-top:auto) and optionally the mb-0 class (margin-bottom:0) to the last <hr> element.

By using the d-flex flex-column classes, you create a flexbox column with h-100 setting its height to 100%. The mt-auto class applied to the <hr> element pushes it down. You can further control the distance from the bottom that the <hr> sits by using the pb-* class on the container. In this case, pb-4 has been selected.

Feel free to click "run code snippet" below and expand it to the full page for testing purposes:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<header class="hero-bg">
    <!-- Start Navigation -->
    <nav class="navbar navbar-expand-md navbar-dark fixed-top">
        <div class="container m-auto nav-line">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-toggle" aria-controls="navbar-toggle" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-center text-uppercase font-alt" id="navbar-toggle">
                <ul class="navbar-nav mt-1">
                    <li class="nav-item">
                        <a href="#texting" class="nav-link">Texting</a>
                    </li>
                    <li class="nav-item">
                        <a href="#eventkonzeption" class="nav-link">Event Konzeption</a>
                    </li>
                    <li class="nav-item">
                        <a href="#impression" class="nav-link">Impressionen</a>
                    </li>
                    <li class="nav-item">
                        <a href="#ueber" class="nav-link">Über mich</a>
                    </li>
                    <li class="nav-item">
                        <a href="#kontakt" class="nav-link">Kontakt</a>
                    </li>
                </ul>
                <!-- navbar-nav -->
            </div>
            <!-- navbar-collapse -->
        </div>
        <!-- container -->
    </nav>
    <!-- Ende Navigation -->
</header>

<!-- Header -->
<section id="home" class="hero-bg jumbotron bg-info pb-0" style="height: 100vh;">
    <div class="container d-flex flex-column h-100 pt-0 pb-4 header-h">
        <hr style="background: white; height: 1px; width: 100%; border: 0">
        <div class="align-items-start row justify-content-center mx-auto">

            <div class="img-logo col align-self-start">
                <img class="img-fluid d-block img-responsive mx-auto" src="https://placehold.it/500x100" alt="Rollywood-Logo" >
            </div>
            <!-- col -->
        </div>

        <!-- row -->
        <hr class="mt-auto mb-0" style="background: white; height: 1px; width: 100%; border: 0">

    </div>

    <!-- container -->
</section>
<!-- Header -->

Additionally, the mx-auto class has been added to the logo image div to center it horizontally.

Answer №2

Everything appears to be in order with your code, except for the <hr> tags being placed within the jumbotron. To resolve this, simply move these hr tags outside of the jumbotron, both before and after it. This adjustment will yield the expected result.

 <!DOCTYPE html>
<html lang="de">

<head>
    <!-- Important Meta Data -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- CSS
  ============================================================================================= -->

    <!-- Bootstrap -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat|Spectral" rel="stylesheet">
    <!-- Simple Line Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.css">
    <!-- Custom -->
    <link rel="stylesheet" href="assets/css/style.css">
<style>
.jumbotron{
height: 100vh;}
</style>
</head>

<body>

    <header class="hero-bg">
    <!-- Start Navigation -->
    <nav class="navbar navbar-expand-md navbar-dark fixed-top">
        <div class="container m-auto nav-line">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-toggle" aria-controls="navbar-toggle" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-center text-uppercase font-alt" id="navbar-toggle">
                <ul class="navbar-nav mt-1">
                    <li class="nav-item">
                        <a href="#texting" class="nav-link">Texting</a>
                    </li>
                    <li class="nav-item">
                        <a href="#eventkonzeption" class="nav-link">Event Konzeption</a>
                    </li>
                    <li class="nav-item">
                        <a href="#impression" class="nav-link">Impressionen</a>
                    </li>
                    <li class="nav-item">
                        <a href="#ueber" class="nav-link">Über mich</a>
                    </li>
                    <li class="nav-item">
                        <a href="#kontakt" class="nav-link">Kontakt</a>
                    </li>
                </ul>
                <!-- navbar-nav -->
            </div>
            <!-- navbar-collapse -->
        </div>
        <!-- container -->
    </nav>
    <!-- End Navigation -->
</header>

<!-- Header -->
       <hr style="background: white; justify-content-start"/>
<section id="home" class="hero-bg jumbotron">
    <div class="container pt-0 pb-5 header-h">
        <div class="align-items-start row justify-content-center">

            <div class="img-logo col align-self-start">
                <img class="img-fluid d-block img-responsive" src="resources/img/logo.png" alt="Rollywood-Logo" >
            </div>
            <!-- col -->
        </div>

        <!-- row -->

    </div>

    <!-- container -->
</section>
           <hr class="align-self-end" style="background: white;"/> 
<!-- Header -->

    <!-- jQuery -->
    <script src="assets/js/jquery-3.2.1.min.js"></script>
    <!-- Popper -->
    <script src="assets/js/popper.min.js"></script>
    <!-- Bootstrap -->
    <script src="assets/js/bootstrap.min.js"></script>
    <!-- Custom -->
    <script src="assets/js/custom.js"></script>

</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

Automate tasks without the need for a traditional form, simply using a text box and a

I've exhausted my search efforts on Google, looking for answers to any question relating to my issue. The webpage I am attempting to submit resembles this setup: there is no form present and the objects are not organized within a form structure. While ...

Is it possible to switch between Jquery and CSS?

Using PHP, I have created a CSS file that enables me to easily adjust the color of various elements. Is there a way for me to regenerate the stylesheet and apply it to the DOM using JQuery? For example: <?php if (isset($_POST['mycolor'])){ $ ...

What is the best way to save and retrieve JavaScript variables on a Blogger page that includes a poll, without needing to host the blog on my own server?

I want to ensure that the valuable feedback provided by users in the poll is not lost. Although the code is a work in progress, the basic concept is there. I did my research before posting this question to avoid redundancy. <script type="text/javas ...

Error on JSP Hello Page

As a novice in JSP, I am attempting to create a simple JSP page where I can set my class fields for name and surname and display them on the page. Below is my Java class: package org.mypackage.person; /** * * @author cemalinanc */ public class Person ...

How can I style my text using CSS with a linear gradient, shadow, and outline effect

Can text be styled with a linear gradient, shadow, and outline all at once? I'm running into an issue where setting "-webkit-text-fill-color: transparent" for the gradient causes the shadow to appear on top of the text. Is there a way to have the te ...

Exploring Angular 6's nested routes and corresponding components for child navigation

I'm currently diving into the concept of lazy loading in Angular 6. Here's a visual representation of the structure of my application: ─src ├───app │ ├───components │ │ ├───about │ │ ├─── ...

The presence of the `class` attribute on the `td` element

Is there a reason why the rows with the "odd" td class in this script do not toggle to blue like the rows without the "odd" class? EDIT: When you click on a row (tr), it is supposed to turn blue (.hltclick) and return to its original color when clicked ag ...

Changing the element tag and flipping escape characters in html entities

My control over the string source is limited, as I can only use html(). However, I am in need of cleaning up the chaos within the source, The goal is to remove all instances of <div class="page"></div>, while retaining its content. The challen ...

Maintain the border styling of a radio button when it is in the selected state

Having an issue with the radio type options - when selected, a blue border appears but disappears if clicking elsewhere. Need the blue border effect to stay even when clicked outside, unless switching to the other option. Looking to align the price in th ...

Library of CSS styling information

Has anyone come across a reliable javascript library that can retrieve the original style (not computed) of a specific element in the DOM? Essentially, I am looking for something that can provide results similar to what is displayed in Firebug's style ...

"Troubleshooting: Why is my jQuery .load function returning an empty div when

Currently, I am developing a PHP control panel and I need a div in one of my PHP files to automatically refresh. After researching, I found a jQuery solution that can reload specific parts of a website automatically. However, the issue I am facing is that ...

Is there a way to relocate the collapse button to the bottom after it has been clicked?

I have been using Bootstrap to design a expandable card that can be expanded when clicked. I am currently using the collapse feature, but I am facing an issue where the button remains in its original position, whereas I want it to move to the bottom of the ...

Guidance on utilizing jQuery to display values depending on a dropdown selection

This code snippet displays movie data from a JSON variable in a dropdown list based on the selected city. It also needs to show the movie name and theaters list when a user selects a movie, along with the theater dropdown remaining unchanged. Here is my H ...

Attempting to toggle the visibility of div elements through user interaction

I'm having an issue with click events on several elements. Each element's click event is supposed to reveal a specific div related to it, but the hidden divs are not appearing when I click on the elements. Any help in figuring out what might be g ...

Function activation in Element requires a double click to initiate

I've encountered an issue with a web element I'm working on where the click function only triggers after the first click, rendering the initial click ineffective. Here's the code snippet in question: HTML: <div> <a href="#0" cla ...

Troubleshooting: Unable to get the :last selector to work

$('.data_row:last').after('<tr class="odd"> <td class="first data" style="min-width: 29px;">2</td></tr>'); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> < ...

Expanding the width of CSS dropdown menus according to their content

When attempting to create a dynamic dropdown menu, I encountered an issue where the values were skewed in Internet Explorer if they exceeded the width of the dropdown. To fix this problem, I added select:hover{width:auto;position:absolute}. However, now th ...

What is the optimal resolution for a background image in a Cordova app?

Currently working on a Cordova application that requires different background images for various screens. Despite using media queries to provide the background image in different resolutions, we are facing an issue where the background image is not displ ...

Transform the appearance of the navigation bar background upon scrolling in Bootstrap

I am trying to change the background color of my navigation bar from transparent to black when scrolling. I want it to function like this template: . Previous attempts using solutions from How to Change Navigation Bar Background with Scroll? and Changing n ...

"Enhance input functionality by updating the value of the text input or resizing the textbox

I've been facing a challenge with updating the value of my input type=text or textbox control text value using jQuery $(window).resize(function(){});. I am aware that the event is triggered because an alert pops up when I resize the browser. Additiona ...