Steps to ensure text is consistently positioned at the bottom of the page using CSS

I have a simple form created using only HTML and CSS, and my goal is to position the "version text" at the bottom of the page. Please refer to the image below for the desired outcome.

Here is the code I am currently using:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8>
... (omitted for brevity)
</body>

</html>

The layout I want to achieve looks like this:

https://i.sstatic.net/kzxua.png

Could someone provide guidance on how to achieve this? Any help or advice would be greatly appreciated!

Answer №1

One possible solution is to implement a responsive design, which allows the window to be resized without encountering any specific issues. Here is an example of how you can achieve this:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>
    <title>Login form</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <style>
        (CSS styles here)
        
    </style>
</head>

<body>

    <main>
        <div class="conta">
            <form action="" id="login-form">
                (Form elements here)
            </form>
        </div>
        
    </main>
    <div class="bottom-links">
        <small class="version">v3.0.</small>
    </div>
</body>

</html>

To ensure proper placement and styling of the .bottom-links div, I positioned it outside the main tag with the following properties:

  • background: transparent to remove the background and prevent interference with other elements;
  • position: fixed to fix the element on the screen;
  • bottom: 10px to position the element 10 pixels above the bottom of the page;
  • z-index: 10 to give the element higher priority in terms of visibility.

NOTE: Additionally, I included the property

inline-size: -webkit-fill-available
to center the .bottom-links elements vertically on the screen.

Answer №2

If you give the attached code a try, it should work smoothly. Should you encounter any issues, feel free to leave a comment, and I'll do my best to assist you.

I've made some modifications to the .bottom-links section and reduced some of the CSS.

As a suggestion for your future coding endeavors, consider utilizing Viewport Units such as vw and vh instead of relying solely on px and %. This approach will enhance the responsiveness of your webpage or website.

... (Code and HTML content remains the same) ...

Answer №3

I have repositioned the .bottom-links element outside of the form and placed it within the main wrapper. I applied the following CSS to position it at the bottom (20px from the bottom edge) and center the text:

.bottom-links {
    position: absolute;
    bottom: 20px;
    text-align: center;
    width: 100%;
}

html,
body {
  height: 100%;
}

* {
  margin: 0;
  padding: 0;
  text-decoration: none;
  font-family: 'Roboto', sans-serif;
  box-sizing: border-box
}

body {
  background-color: #f9fbff
}

.source-image {
  width: 100%;
  background-repeat: no-repeat;
  background-size: auto;
  position: fixed;
  max-width: 100%;
  display: block
}

#login-form {
  width: 460px;
  background: 0 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 20px 0
}

.input_img {
  position: absolute;
  bottom: 20px;
  left: 13px;
  height: 30px
}

#login-form h1 {
  text-align: center;
  margin-bottom: 60px;
  color: #191c3c;
  font-size: 30px
}

.logoHolder>img {
  width: 60%;
  margin-bottom: 30px;
  margin-left: auto;
  margin-right: auto;
  display: block
}

#login-form p {
  font-size: 16px;
  color: #333
}

#login-form p a {
  color: #191c3c;
  text-decoration: underline;
}

#login-form p {
  font-size: 16px;
  color: #333
}

#login-form .entryText {
  font-size: 18px
}

#login-form p a:focus {
  border: 1px solid #515772
}

#login-form label {
  color: #4a4d67;
  font-weight: 700;
  margin-bottom: 10px !important
}

.input-box {
  position: relative;
  margin: 30px 0
}

.input-box input {
  font-size: 15px;
  color: #333;
  border: 1px solid #51577245;
  width: 100%;
  line-height: 1.2;
  font-size: 18px;
  outline: 0;
  background: #fff;
  padding: 0 5px;
  height: 72px;
  border-radius: 5px;
  padding-left: 57px;
  box-shadow: 0 3px 11px 0 rgba(81, 87, 114, .2);
  margin-top: 15px
}

.input-box input:focus {
  border: 1px solid #515772
}

.input-box span::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 50%;
  left: 5px;
  color: #515772;
  transform: translateY(-50%);
  z-index: -1;
  transition: .5s;
  padding-left: 20px
}

.validation {
  border-color: #c00000 !important;
  margin-bottom: 7px;
}

.feedback {
  color: #c00000;
}

 ::placeholder {
  margin-left: 60px;
  color: #8b8d9d;
  font-size: 14px;
  font-weight: 700;
}

.cursor {
  width: 17px
}

.input-box span::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  background: linear-gradient(120deg, #2196F3, #FF5722);
  transition: .5s
}

.focus+span::before {
  top: -5px
}

.focus+span::after {
  width: 100%
}

.login-btn {
  display: block;
  width: 100%;
  height: 62px;
  border: none;
  background: #515772;
  background-size: 200%;
  color: #fff;
  outline: 0;
  cursor: pointer;
  margin: 20px 0 0;
  border-radius: 8px;
  transition: .5s;
  font-size: 18px;
  letter-spacing: 1px;
  font-weight: 700
}

.login-btn:focus {
  border: 2px solid #000
}

.login-btn:hover {
  background-color: #2d3142
}

.bottom-links {
  margin-top: 30px;
  text-align: center;
  font-size: 13px
}

.bottom-links>p>a {
  text-decoration: underline;
}

.bottom-links>p {
  margin-bottom: 10px;
}

@media (max-width:768px) {
  #login-form {
    top: 40%;
    padding: 0;
  }
  .source-image {
    display: none
  }
}

@media (max-width:1440px) {
  .source-image {
    display: none
  }
}

.version {
  font-size: 14px;
  margin-top: 10px;
}

.conta {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.bottom-links {
  position: absolute;
  bottom: 20px;
  text-align: center;
  width: 100%;
}
<body>

  <main>
    <div class="conta">
      <form action="" id="login-form">
        <div class="logoHolder">
        </div>
        <div class="input-box"><label for="username">Username</label><input id="username" name="username">
        </div>
        <div class="input-box"><label for="password">Password</label><input id="password" name="password" type="password" placeholder="">         </div>
        <button type="submit" class="login-btn" aria-label="Prijava gumb">Enter</button>
      </form>
    </div>
    <div class="bottom-links">
      <small class="version">v3.0.</small>
    </div>
  </main>
</body>

Answer №4

Experience the power of positioning by trying out bottom styling combined with relative positioning for optimal webpage element placement.

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

Submitting documents via jQuery post

I am facing an issue with my HTML form where I am trying to upload an image file. After submitting the form, I use JavaScript to prevent the default action and then make a jQuery post request (without refreshing the page) with the form data. However, despi ...

How about this: "Implement a slider in the header of a php

I am looking to add a slider to the header of my phpBB website. I have inserted the code into template/overall_header.html but it doesn't seem to be working. As someone who is new to phpBB, any assistance would be greatly appreciated. ...

Media query failing to target HTML form element

Is it possible to dynamically adjust the font size of form labels and input fields based on browser width? I've heard that fonts can't automatically 'scale down' when the browser width decreases, requiring media queries instead. I atte ...

Is there a way to verify and send notifications when duplicate entries are added to my table?

Whenever a make and model are added using the "add" button, I need to ensure that there are no duplicates. If a duplicate is found, an alert should be displayed, and the entry should not be added to the table. Unfortunately, I have been unable to find a so ...

Floating multiple block-level elements within an <li> tag in HTML allows for greater control over the layout and

I am facing a complex issue that requires attention. Let me explain the situation: There is an unordered list consisting of list items displayed vertically with alternating background colors, all having the same width within a fixed-width div. Some list i ...

There is a significant distance between the columns, causing the text to appear misaligned and not left-

I'm encountering an issue with the alignment of a row with two columns. The first column contains an image, and the second column contains text. However, the text is not aligning properly next to the image. <link href="https://cdn.jsdelivr.net/ ...

The items in column 2 are unexpectedly switching positions when viewed on mobile, which is not intended

Whenever I toggle a switch, certain sections are displayed on the screen. However, when I activate this switch, the column layout suddenly changes to look like the mobile view, with two images stacked vertically instead of side by side. I'm using col- ...

Tips for adjusting the reCAPTCHA popup to fit within the dimensions of a mobile screen

When attempting to debug an application, I encountered an issue with the reCAPTCHA window. The placement of the window is a bit off, causing the Verify button to be out of view. This prevents me from progressing past that page as I am unable to confirm the ...

What is the best way to ensure that CSS links resolve properly when incorporating a PathInfo value?

Having an issue with my asp.net 3.5 app. Whenever I try to add a value to the URL for Request.PathInfo, it seems like I lose all connections in the head section because the paths are resolved as relative. This is how the master page appears: <head id= ...

After incorporating additional HTML elements, the typeahead feature fails to retrieve data from the table

Trying to implement an autocomplete search feature using typeahead.js. The code I tested is functioning perfectly and displaying the suggestion list as expected. Controller public function autocomplete(Request $request){ $data = Product::sel ...

When I click the mouse, my drawing function starts lines from the top left corner instead of the latest point

http://codepen.io/FreelanceDev/pen/kLpJSf?editors=1010 You can find my CodePen project through the provided link. While the HTML and CSS elements are working correctly, I am facing issues with the JavaScript functionality. The desired outcome should be d ...

Mac users may experience lag when using Javascript parallax effects

I created a parallax page where the background image changes using JavaScript translateY(- ... px)' similar to what you see on the firewatch website. On Windows, the parallax effect works smoothly. However, on macOS it is smooth only in Safari. All ...

Collapsible Rows in Material-UI Table seamlessly integrated with regular rows

While using material-ui v4, I encountered an issue where my collapsible row columns are not aligning properly with my regular columns. Below is a photo and the code snippet for reference. As you can see in the image, when I expand the Frozen Yogurt row, th ...

Discovering HTML tags on a mobile browser with switmailor

We have created a form and are using the Swiftmailer library to send its data via email. If a user fills out the form from a desktop browser, the data appears correctly without any HTML tags. However, if the user fills out the form from a mobile browser, ...

Refreshing data dynamically using Ajax along with the feature of pagination

I'm currently working on retrieving data about animals and their speeds from an API. https://i.sstatic.net/w2xCA.png The data is supposed to be stored in a table with 5 columns, resembling the following: https://i.sstatic.net/K9S5w.png Below is th ...

The onclick handler fails to function following the injection of html using jquery AJAX

After using ajax to inject HTML into my page, the onclick handler on a specific part of that injected HTML does not seem to be functioning... Specifically, I am referring to this image... < img class="close_row" src="img/close.gif"/> In jQuery, I ...

Looking to deactivate a particular checkbox in a chosen mode while expanding the tree branches

I encountered an issue with a checkbox tree view where I needed to disable the first two checkboxes in selected mode. While I was able to achieve this using the checked and readonly properties, I found that I could still uncheck the checkboxes, which is no ...

Save the outcomes of the response in variables

I've been working on incorporating newsapi.org's API function into my website to display headlines. The function works smoothly when tested in the Chrome console, but I'm struggling with accessing the results within the array it returns. Her ...

Determine the presence of a value within a specific column of an HTML table using jquery

When I input an ID number into a textbox, it shows me the corresponding location on a scale in another textbox. You can see an example of this functionality in action on this jsFiddle: http://jsfiddle.net/JoaoFelipePego/SdBBy/310/ If I enter a User ID num ...

Tips for adding a border to an element when hovered over

I am looking to achieve a hover effect that displays a border around an element without actually adding the border to the element itself, as shown in this image: https://i.sstatic.net/iFpCA.png The challenge I'm facing is that I want to allow users ...