The div element is not aligned in the center and the footer is shifting

My goal is to have the "home" div centered on the page. However, I am facing an issue where when I shrink the browser window, the footer moves up and eventually disappears underneath it. Also, if I zoom out on the page, I can see that the logo and text are not in the middle as intended.

I'm struggling to keep the footer at the bottom while ensuring that the logo and text are aligned in the center of the page.

The framework I am using is Bootstrap 5

CODE: https://jsfiddle.net/esznkh4r/3/

VIDEO:

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.home {
  padding-top: 150px;
}

.logo {
  height: 200px;
   width: 200px;
  border-radius: 100%;
}

.text {
  text-transform: uppercase;
  text-align: center;
}

footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height:50px;
}
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88eae7e7fcfbfcfae9f8c8bda6baa6b8">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff9d90908b8c8b8d9e8fbfcad1cdd1cf">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
      </ul>
    </div>
  </div>
</nav>


    <div class="wrapper">
        <div class="home">
            <div class="container">
                <img class="logo d-block mx-auto mb-4" src="https://duckduckgo.com/assets/common/dax-logo.svg" alt="LOGO">
                <div class="text">
                    <h1>TEST</h1>
                    <h6>BLABLABLABLABLA</h6>
                </div>
            </div>
        </div>
    </div>

    <footer>
        <div class="container d-flex flex-wrap justify-content-between align-items-center py-3">

            <div class="col-md-4 d-flex align-items-center">
                <span>TEST</span>
            </div>

            <ul class="nav col-md-4 justify-content-end d-flex">
                <a class="mb-0 justify-content-end" target="_blank">TEST</a>
            </ul>
        </div>
    </footer>

Answer â„–1

You can attempt it in this way.

Adjust the flex attribute within the .container.

Sample Code

Answer â„–2

One potential solution is to eliminate the styling associated with the .home class and replace it with the following:

.wrapper {
   flex: 1;
   display: flex;
   align-items: center;
   justify-content: center;
}

Answer â„–3

Recently included a new property in the .home class

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.home {
  padding: 150px 0;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200px;
   width: 200px;
  border-radius: 100%;
}

.text {
  text-transform: uppercase;
  text-align: center;
}

footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height:50px;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9cbc6c6dddadddbc8d9e99c879b8799">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa8a5a5beb9beb8abba8affe4f8e4fa">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
      </ul>
    </div>
  </div>
</nav>


    <div class="wrapper">
        <div class="home">
            <div class="container">
                <img class="logo d-block mx-auto mb-4" src="https://duckduckgo.com/assets/common/dax-logo.svg" alt="LOGO">
                <div class="text">
                    <h1>TEST</h1>
                    <h6>BLABLABLABLABLA</h6>
                </div>
            </div>
        </div>
    </div>

    <footer>
        <div class="container d-flex flex-wrap justify-content-between align-items-center py-3">

            <div class="col-md-4 d-flex align-items-center">
                <span>TEST</span>
            </div>

            <ul class="nav col-md-4 justify-content-end d-flex">
                <a class="mb-0 justify-content-end" target="_blank">TEST</a>
            </ul>
        </div>
    </footer>

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

Tips for aligning field labels and items together on one line, even when the item is spread across multiple lines

I need to showcase a comprehensive list of countries: Countries: Angola, Botswana, Burundi, Comoros, DR Congo, Djibouti, Egypt, Eritrea, Ethiopia, Kenya, Lesotho, Libya, Madagascar, Malawi, Mauritius, Mozambique, Namibia, Rwanda, Seychelles, South Africa, ...

Resolving conflicts between Bootstrap and custom CSS transitions: A guide to identifying and fixing conflicting styles

I am currently working on implementing a custom CSS transition in my project that is based on Bootstrap 3. The setup consists of a simple flex container containing an input field and a select field. The functionality involves using jQuery to apply a .hidde ...

What is the best way to assign two styles with the same value in a single line of code?

Can you suggest a simpler method for expressing left:15%;right:15%, such as using left,right:15% or something equivalent? Your assistance is greatly appreciated! ...

Scrolls down to the bottom of the Material-UI popover menu

Trying to incorporate a material-ui popover with a scrollable menu <Popover {...popoverProps}> <Menu className="ui-dropdown-menu">{items}</Menu> </Popover> Custom styles applied: popoverStyle: { height ...

What is the best way to turn off autocorrect in a textarea on IE11 without turning off spellcheck?

In my experience, disabling the spellcheck attribute seems to solve the auto-correct issue, but it also eliminates the underlining of misspelled words. <textarea id="TextArea1" spellcheck="false"></textarea> I prefer to keep spellcheck enabl ...

Centering text in a pseudo element vertically

I’ve been trying to find a way to centrally position vertically an ::after pseudo-element that includes text (a content attribute). Previous inquiries: I reviewed some previous inquiries on this topic, however, none of the solutions seem to apply to thi ...

HTML integration of JavaScript not working as expected

My experience with separating files in HTML and JS has been positive - everything works smoothly when I link the JS file to the HTML. However, an issue arises when I decide to include the JS code directly within <script> tags in the HTML itself. The ...

Comparing the use of jQuery click event with the button to trigger a function that calculates the

Currently, I am grappling with a JQuery function that checks if any checkboxes are ticked within my form. My version of JQuery is v1.10.2. The code functions as expected when triggered by a button, but when I attempt to trigger it with a checkbox within t ...

Unable to retrieve the following element in a JavaScript array

I am a beginner in JavaScript and I am attempting to access the next element of an array using an onclick function but so far I have not been successful. var i, len; function quiz() { var quiz_questions = [ "who is the founder of Fa ...

Carving out an SVG Mask within an image

I'm encountering an issue with a new website I'm working on. This is my first time utilizing SVG's. Essentially, I need to crop a circle that remains centered on the page from my image to reveal the image beneath the element. Although I atte ...

The buttons on the Bootstrap Carousel are unresponsive and the indicators are not displaying as they should

I am currently attempting to replicate a bootstrap carousel that includes indicators. However, in my code, I am unable to view the indicators, and the previous/next buttons are not functional. Although I came across a workaround that I could modify from th ...

Adjust the <h1> tag's size using responsive Bootstrap design

Is it possible to adjust the font size of the <h1> tag specifically for small and extra small screens? The default size of the <h1> tag is suitable for medium screens but appears very large on small and extra small screens. I would like to cu ...

Guide to showcasing two spring models within a single HTML table row utilizing Thymeleaf

I need help formatting a row to display in an HTML table: "$num out of $totalCount" For example, if num=5 and totalCount=8, I want it to show as 5 out of 8. This is the code I have so far: ... <tr> <td th:text=&quo ...

Creating multiple div elements with changing content dynamically

I am facing an issue with a div named 'red' on my website where user messages overflow the 40px length of the div. To prevent this, I want to duplicate the 'red' div every time a message is sent so that the messages stay within the boun ...

Stylesheets per module in Angular 2

For my website design, I've decided to adopt a modular structure using sass. To ensure consistency throughout the module, instead of defining stylesheets at the component level, I plan to define them at the module level and import them into each compo ...

Include HTML tag and class inside a JavaScript code block

A dynamic button is loaded when a certain condition in the JavaScript is met. Upon loading, I want to trigger a function (ClickMe) by clicking the button. However, I'm facing difficulty connecting the function with the button in my code. In my scrip ...

What is the best way to adjust a fixed-width table to completely fill the width of a smartphone browser?

In an ancient web application, the design was primarily constructed using rigid tables: <div class="main"> <table width="520" border="0" cellspacing="0" cellpadding="0"> <tr> <td>...</td> </ ...

Show using foreach, with a modification of the spacing between rows and columns

For my project, I need to display the same image 24 times with a 3x8 matrix on an A4 size page using a foreach method. The issue I'm encountering is that I have to manually add space between each row and column, but it cannot cause the page to break. ...

Ways to adjust the size of the parent element based on the height of a specific element

I am faced with a situation where I need to identify all elements belonging to a specific class and adjust the padding-bottom of their parent div based on the height of the matched element. For example, consider the following structure: <div class=&ap ...

When an HTML email is sent from the Outlook 2007 Exchange server, it may appear as plain text when viewed on

After extensive searching, I've come across two old threads with unanswered questions on this topic. In our office, we have a Windows XP PC designated for "production" that sends out emails in HTML format. These emails contain multiple excel Cells for ...