Tips for positioning a 404 message at the center of a webpage

Struggling with centering a 404 error message on your Bootstrap 5 page without messing up the footer layout? When the viewport is small, the 404 message may end up getting covered by the footer. Feel free to check out the code snippet in full view to see how the current 404 page appears.

/* body {
    margin: 0;
    padding: 0;
    font-family: "Montserrat", sans-serrif;
    min-height: 100vh;
} */

#error-message {
    text-align: center;
  position: absolute;
  top:50%;
  transform: translateY(-50%);
}

#footer {
    position: absolute;
  bottom: 0;
  width: 100%;
}



 footer p {
    padding-top: 8px !important;
  }
  
  @media screen and (min-width: 768px) and (max-width: 991px) {
    footer h4 {
      min-height: 56px;
    }
  } 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <title>404 |  </title>
    <link rel="stylesheet" href="./css/404.css>
    <link rel="stylesheet" href="/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css" />
<link href="https://cdn.jsdelivr.net/npm/email-protection(cbbbd2c803c2d6dbdbc1cda158756b65cbcddb2)" rel="stylesheet">

<!-- More links... -->

<script src="https://cdn.jsdelivr.net/npm/email-protection(91326f6f74747476757070357461746281386578)/dist/js/bootstrap.bundle.min.js></script>


<!-- Page content starts here -->
    <div class="container"id="error-message">
        <h2>Oops! Page not Found</h2>
            <h1>404</h1>
            <p>Sorry, we can't find the page you are looking for.</p>
            <p>If you clicked a link on our site and were deirected to this page please contact us so we can fix the problem.</p>
            <a href="./index.html>Go back home</a>
    </div>

    <!-- Footer section -->
    <footer class="bg-dark text-white" id="footer">
          <!-- Footer content goes here -->
    </footer>
      <!-- End of footer section -->
</body>
</html>

Answer №1

#error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10%;
}

#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}

footer p {
  padding-top: 8px !important;
}

@media screen and (min-width: 768px) and (max-width: 991px) {
  footer h4 {
    min-height: 56px;
  }
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>404 | </title>
  <link rel="stylesheet" href="./css/404.css">
  <link rel="stylesheet" href="/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css" />
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80e2efeff4f3f4f2e1f0c0b5aeb3aeb0">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <link rel="stylesheet" data-purpose="Layout StyleSheet" title="Default" disabled href="/css/app-937c1ff7d52fd6f78dd9322599e2b5d4.css?vsn=d">
  <link rel="stylesheet" data-purpose="Layout StyleSheet" title="Web Awesome" href="/css/app-wa-8d95b745961f6b33ab3aa1b98a45291a.css?vsn=d">

  <link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.4.0/css/all.css">

  <link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-solid.css">

  <link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-regular.css">

  <link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-light.css">
  <link rel="icon" type="image/x-icon" href="/Bootstrap-Technovine/images/favicon-32x32.png">
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e0c01011a1d1a1c0f1e2e5b405d405e">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
</head>

<body>
  <!-- 404 CONTENT START -->
  <div class="container" id="error-message">
    <h2>Oops! Page not Found</h2>
    <h1>404</h1>
    <p>Sorry, we can't find the page you are looking for.</p>
    <p>If you clicked a link on our site and were deirected to this page please contact us so we can fix the problem.</p>
    <a href="./index.html">Go back home</a>
  </div>
  <!-- 404 CONTENT CLOSE -->
  <!-- FOOTER SECTION START -->
  <footer class="bg-dark text-white" id="footer">
    <div class="container">
      <div class="row mb-2">
        <div class="col-md-3 mt-5">
          <h4>About Us</h4>
          <hr />
          <p>We are skilled IT professionals who specialize in solving a range of problems that our clients may face in the realm of IT.

          </p>
          <!-- FACEBOOK SECTION -->
          <a href="">
            <i class="fa-brands fa-facebook fa-2x"></i>
          </a>

          <!-- INSTAGRAM SECTION  -->
          <a href="">
            <i class="fa-brands fa-instagram fa-2x"></i>


          </a>

          <!-- TWITTER SECTION -->
          <a href="">
            <i class="fa-brands fa-twitter fa-2x"></i>

            <!-- LINKEDIN SECTION -->
          </a>
          <!-- <a href="#">
                <i class="fa-brands fa-linkedin fa-2x"></i>
              </a> -->

          <!-- WHATSAPP SECTION -->
          <!-- <a href="#">
                <i class="fa-brands fa-whatsapp fa-2x"></i>
              </a> -->

        </div>
        <div class="col-md-3 mt-5">
          <h4>Quick Links</h4>
          <hr />
          <ul class="navbar-nav">
            <li class="nav-item"><a href="/index.html" class="nav-link">Home</a></li>
            <li class="nav-item"><a href="/about.html" class="nav-link">About</a></li>
            <li class="nav-item"><a href="/services.html" class="nav-link">Services</a> </li>
            <li class="nav-item"><a href="/contact.html" class="nav-link">Contact</a> </li>
          </ul>
        </div>

        <div class="col-md-3 mt-5">
          <h4>Privacy and Terms</h4>
          <hr />
          <ul class="navbar-nav">
            <li class="nav-item"><a href="#" class="nav-link">Privacy Policy</a></li>
            <li class="nav-item"><a href="#" class="nav-link">Terms & Coniditions</a></li>
            <li class="nav-item"><a href="#" class="nav-link">API Documentation</a> </li>
          </ul>
        </div>
        <div class="col-md-3 mt-5">
          <h4>Contact Info</h4>
          <hr />
          <p class="text-white">
            city, state 12345 <br /> Call Us Now 123-456-7890 <br />

          </p>
        </div>
      </div>
    </div>
    <div class="bg-dark text-white text-center py-4" id="copyright">
      Copyright &copy; 2023 . All Rights Reserved.
    </div>
  </footer>
  <!-- FOOTER SECTION CLOSE -->
</body>

</html>

This HTML code has been slightly modified with some changes in CSS. Hopefully, these adjustments are helpful.

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

Exclude a specific tag from a div in JavaScript

I need help selecting the text within an alert in JavaScript, excluding the <a> tag... <div id="addCompaniesModal" > <div class="alertBox costumAlertBox" style="display:inline-block;"> <div class="alert alert-block alert- ...

Want to learn how to display a description below a photo when you hover over it in a photo gallery?

I am currently creating a basic photo gallery where hovering over a thumbnail displays an enlarged photo below it. My goal is to also have text displayed inside a white text box when hovering over each thumbnail, with unique descriptions for each. I need ...

Can you help me understand how to ensure the CSS translate feature lands in a specific div, no matter its initial position?

I'm facing a roadblock in my journey to create a card game. The issue arises at the final stage of the Translate function implementation. In this game, the player is dealt 30 cards (I've simplified it to four for ease of programming), and upon cl ...

Utilize/Absolve/Add a Prefix to angular material scss styles

Issue I am facing a challenge with integrating angular material SCSS into my application. I want to ensure that these styles are isolated and scoped specifically for my application, as it will be embedded within a larger monolith. The goal is to prevent a ...

Exploring intricate binding expressions using IF statements in ASP.NET

I am trying to create an expression for a column in my repeater, but I am not confident about the syntax. My goal is to display "No Document" if the value is equal to "DispForm.aspx", otherwise show the actual value. I attempted to combine all expression ...

Utilize a Dropdown Menu to Retrieve Information from a Database and Display the Results on Either the Current Page or a Separate Page

My PHP page includes a code snippet that generates an HTML table: <table> <thead> <tr> <th class="wheniwant">Date</th> <th class="wheniwant">Income Amount</th> <t ...

tips for displaying a label and text side by side on a single line

Is there a way to keep my label and text on the same line by adjusting the CSS? I've tried using float based on suggestions from other posts, but they still end up on different lines. .indentColumn { width: 71px; padding-top: 5%; } .labelColumn ...

Looking to create a responsive image in a liquid file on Shopify

Recently, I added a new feature to my Shopify backend where users can upload images to a page. While I can see the images on the front-end, they are currently aligned to the right. My goal is to make these images responsive by default and expand to fit the ...

Difficulty maintaining consistent line widths while setting up a CSS border grid on a table

What is the most effective method for creating a table with a 1px grid (internal and external)? Could it be possible that Chrome and Edge have issues with borders in certain scenarios? On this Codeply example, the standard approach is taken - setting bord ...

Exploring CSS shaders in a browser?

Which browser out there fully supports CSS shaders? ...

Transfer file content by dragging and dropping it onto a TextArea when an anchor tag is dropped

Within my application, there are 2 textareas with corresponding code implementing "dragover" and "drop" listeners for each one: // for dragover handleDragOver : function (evt) { var self = this; evt.preventDefault(); console.log ( ...

Tips for utilizing dynamic variables when setting props in React Native styles

I am encountering an issue while trying to set props in the stylesheet to dynamically change the background color based on data received from the server. undefined is not an object (evaluating 'this.props.colorCode') Below is the snippet of my ...

Is it possible to utilize various return values generated by a regex?

Working on a project where I am utilizing regex to extract links from a Google Calendar XML feed. The links appear in the following format: <a href="http://www.drsketchysdublin.com/event-registration/?ee=11">http://www.drsketchysdublin.com/event-reg ...

How to toggle between two background colors in a webpage with the click of a button using JavaScript

I need help with a unique website feature. I want to implement a button that cycles between two different background colors (white and black) as well as changes the font color from black to white, and vice versa. My goal is to create a negative version of ...

How to style the videojs chapter menu with CSS to extend the box to the full length of the line

I am currently working on customizing the videojs CSS for the ChapterButton menu in order to make it expand to accommodate varying line lengths without wrapping. Even though I can set it to a fixed width, I require it to be able to adjust to different line ...

Add JavaScript and CSS files from the node_modules folder to enhance a static HTML webpage

Currently, my development server is set up using node's live-server. However, for production, I plan to use a LAMP server. Within my node_modules directory, I have the normalize.css file. In my index.html, I currently link to it like this: <link ...

Switch between input and the input is not displayed inline

I've been struggling to align the Toggle button with the input box for quite some time now. I really need them to be inline so that they form a grid properly as everything is dynamic. I have experimented with using a Div on its own instead of a label ...

Can you provide a tutorial on creating a unique animation using jQuery and intervals to adjust background position?

I am attempting to create a simple animation by shifting the background position (frames) of the image which serves as the background for my div. Utilizing Jquery, I aim to animate this effect. The background image consists of 6 frames, with the first fr ...

Is Adsense flexibility the key to achieving the perfect fluid layout?

I've successfully created a CSS 3 column fluid layout, thanks to everyone's help! In my left column, I have a Google AdSense advert. Unfortunately, the sizes of these adverts are not very flexible. I'm wondering if there is a way to change t ...

Enhance the appearance of radio buttons using CSS and incorporate images to create a

Is there an easy and straightforward method to customize radio buttons using only CSS, allowing me to click on an image instead of a traditional bullet point? For example, like thumbs up/thumbs down. I have two radio buttons that need to track which one i ...