What could be the reason for the div not filling up the available space?

I've made changes to the semiHero class by adding a display:block;. However, it's not taking up the space as expected and isn't pushing the container with the hr below the entire div. I want the semi-hero to occupy the space so that it pushes the container down.

View the image of the situation here.

Below is the relevant code snippet:

 .semiHero {
        background-image: url("../assets/semiHero.png");
        height: 50%;
        width: 100%;
        background-position: center;
        background-repeat: scroll;
        background-size: cover;
        position: absolute;
        display: block;
    }
       <div class="semiHero">
            <div class="container" id="NavMain">
                <nav class="navbar navbar-custom navbar-expand-lg navbar-light">
                    <a class="navbar-brand" href="#">Logo</a>
                    <button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav"
                        aria-expanded="false" aria-label="Toggle navigation" id="hamburger">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse justify-content-end" id="navbarNav">
                        <ul class="navbar-nav navbar-custom">
                            <li class="nav-item active">
                                <a class="nav-link" href="#">Start
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="#">About Me</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="#">Work</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="#">Contact</a>
                            </li>
                        </ul>
                    </div>
                </nav>
                <div class="hero-text">
                    <h1>May I Introduce Myself?</h1>
                    <hr>
                    <h2>Frontend Design | UI/UX Design</h2>
                    <br>
                </div>
            </div>
            <button id="goAhead">Go Ahead</button>
        </div>
        <!-- MainSection -->
        <div class="container">
            <div class="row">
                <div class="col" id="Name">
                    <h1>
                        Raphael Lechner.
                    </h1>
                </div>
            </div>
        </div>

Answer №1

position: absolute shifts the element in relation to its closest ancestor. Because of this, the element is taken out of the normal document flow and does not occupy any space.

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 get input from a select box using Thymeleaf?

Recently, I've been working on a school project where I started learning Java Web/Spring/Bootstrap just a week ago. If any of my ideas are wrong, feel free to correct me. I was following an online tutorial and managed to fetch user input using Thymel ...

Tips for embedding a form within a table that includes a while loop

I am struggling to get a form to work inside a table that is generated by a while loop. The submit button in the code provided is not functioning properly. I have also attempted to place the form tag before the table tag, but this causes all the data to ...

Changing the border color of a Bootstrap 5 button using custom CSS styling

I have been working on a page to control my amp using various JavaScript libraries. 1.) How can I change the blue border of a selected Bootstrap 5 button to a lighter green without using SCSS? Example: Repository (apologies for the mess, it's not t ...

Choose the OK button on the modal during the testing phase

I am having difficulty selecting an element on my webpage using testcafe because I am not very familiar with selectors. I am open to choosing it in the JSX or HTML, but I am struggling with both methods. Once I click the "LayerAddingPopUpButton", a modal a ...

What could be causing the JavaScript on my website to not function properly?

I've encountered an issue with the script on my website. Despite double-checking everything and following a tutorial closely, it still doesn't seem to work. Any suggestions or ideas? Here are the links to my GitHub repository and a preview of th ...

What is the distinction between using localStorage and storing individual files when clicking?

Recently, I created a basic jQuery script that stores values such as "voted1", "voted2", and "voted3" in localStorage. However, I encountered an issue where all values are stored simultaneously on click, whereas I require them to be stored individually per ...

Insert a picture within the text input field

I'm facing a specific scenario where I need to add text followed by an image, then more text followed by another image and so on. Please see the input text with values in the image below. Can someone guide me on how to accomplish this with jQuery and ...

Is there a way to position the logo/brand text to the left, the menu in the center, and the search

I've been working on creating a Navbar in Bootstrap 5 with a specific layout. My goal is to have the Logo (which is essentially fancy text) align to the left, center the menu, and place the search field on the right. However, I've encountered an ...

Create a Boostrap navbar with a form and links aligned to the right using the navbar

I'm trying to use navbar-right on a navbar-form and a navbar-nav, but the form ends up on one row and the nav links on another row on the right. How can I make the navbar display the brand on the left and have a search field followed by nav links on t ...

The pointer cursor seems to be missing in action

Currently using ReactJS, I have implemented a custom upload image button on my webpage. .upload-btn-wrapper { position: relative; overflow: hidden; display: inline-block; cursor: pointer; } .upload-btn-wrapper input[type=file] { font-size: 10 ...

How can you prevent an element from overflowing when employing window.pageYOffset and using a switch case to alter the background color at specified pixel thresholds?

I want the <body> element's background-color to change every 500px as I scroll down. I've scoured the web for answers, but still can't figure out what's going wrong. Please review the code. However, Firefox Browser indicates that ...

Show a brief description alongside multiple post thumbnails

I have successfully uploaded multiple featured images to my WordPress website using the multiple post thumbnail plugin. Now, I want to showcase them all below the content along with their descriptions. While I have managed to display the main featured imag ...

Retrieving input values with JQuery

HTML <td data-title="Quantity"> <div class="clearfix quantity r_corners d_inline_middle f_size_medium color_dark m_bottom_10"> <button class="btn-minus bg_tr d_block f_left" data-item-price="8000.0" data-direction= ...

What is the process for translating a single line of code from jQuery to vanilla JavaScript?

How should the code block $('#output').on('input ','.dynamic-Qty', function(e){ be handled? $('#output').on('input ','.dynamic-Qty', function(e){ let z = e.target.dataset; console.log(z.id) conso ...

Obtaining a single element from a hidden display while dragging using Jquery UI

Is there a way to move an element outside of a container with overflow hidden when using drag and drop functionality in CSS? Currently, when I drag an element with the "item" class, it stays within the confines of the container with overflow set to hidden. ...

Difficulty in centering two equal-sized columns in a Bootstrap 3 row with an offset

Here is a link to my demonstration on JSFiddle: https://jsfiddle.net/nbd2w3zb/ I am working with Bootstrap 3 and have created 2 equal-sized columns (.col-md-4) within a .row. The desired effect is to center both of these columns inside the .row, ensuring ...

The Ruby on Rails application is having trouble detecting the stylesheet in the assets

I'm having some trouble displaying a border on my buttons. The button styles are defined in the app/assets/stylesheets/modules/_buttons.scss file, which I have imported into application.scss. @import "bootstrap-sprockets"; @import "bootstrap"; //m ...

Mastering the art of CSS horizontal centering: achieving perfect alignment with floating elements

Struggling to center a button among floating elements? Look no further! button { float:left; } header { overflow: hidden; background: #222; } header a, header label { display: block; padding: 20px; color: #fff; text-decoration: none; ...

The downloading functionality of anchor tags is not functioning properly on mobile devices

In the process of developing a mobile app using Ionic Framework, AngularJs, and Html, I encountered an issue. There is a specific page where users are supposed to click on a <div> element to download a wallpaper image. Strangely enough, this works ...

Center-align the table element

I've been struggling to center align this table element, specifically the one containing the square, but nothing seems to be working. Can anyone lend a hand in fixing this issue? <table> <tbody> <tr> <td>TURKEY - SU ...