Step-by-step guide on building a footer with relatively positioned elements

Is there a way to create a footer that stays at the bottom of the screen but also expands from the top based on the position of a specific element? I want it to have a fixed bottom position while adjusting its top side as needed. How can I achieve this?

.main {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
.content {
  position: relative;
  margin-left: 10%;
  margin-right: 10%;
}
.left-content {
  float: left;
  margin: 2.27272727272727%;
  /* 20/880 = 0.0227272727272727 */
  width: 56.81818181818182%;
  /* 500/880 = 0.5681818181818182 */
  background-color: aquamarine;
}
.right-content {
  float: left;
  margin: 2.27272727272727%;
  /* 20/880 = 0.0227272727272727 */
  width: 34.09090909090909%;
  /* 300/880 = 0.3409090909090909 */
  background-color: mediumturquoise;
}
.inner-content {
  float: left;
  margin: 2%;
  /* 10/500 = 0.02 */
  width: 44%;
  /* 220/500 = 0.44 */
  background-color: darkgreen;
}
.footer {
  clear: both;
  height: 10%;
  bottom: 0px;
  width: 100%;
  position: absolute;
  background-color: darkcyan;
}
<div class="main">
  <div class="content">
    <div class="left-content">
      <h1>A</h1>
      <p>asd</p>
      <p>asd</p>
      <p>asd</p>
      <p>asd</p>
      <p>asd</p>
      <div class="inner-content">
        <h1>D</h1>
      </div>
      <div class="inner-content">
        <h1>D</h1>
      </div>
    </div>
    <div class="right-content">
      <h1>B</h1>
      <p>asd</p>
      <p>asd</p>

    </div>
  </div>
  <div class="footer">
    <h1>C</h1>
  </div>
</div>

Answer №1

From my understanding of your inquiry, you aim to ensure the footer remains at the bottom of the screen consistently. Is that accurate?

To achieve this, simply incorporate the following code snippet into your footer class.

    position: fixed;
    bottom: 0;

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

A workaround for background-size in Internet Explorer 7

Currently, I am working on a project at this link: Everything seems to be functioning well in Firefox and Chrome, however, I have encountered an issue with the background-size property not being supported in IE7. I heavily rely on this property throughout ...

Why isn't the input appearing on the succeeding line below?

<label for="email2">Enter Your Email Address</label> <input type="text" name="email2" id="email2" placeholder="example: [email protected]"> <label for="phone2">Phone Number</label> <input type="text" name="phone2" id= ...

Text within the div element causes the displacement of other adjacent div elements

When the text in mondaySpecial extends to a second line, it pushes tuesdaySpecial-saturdaySpecial further down on the page, disrupting the layout of the divs. The same issue occurs with other specials as well. Is there a way to prevent this from happening? ...

Adjust the alignment of text within the <select> tag to the right in Safari browser

Is there a way to align text right in a select option tag? <select style="direction:rtl;text-align:right"> <option value="" selected="">همه</option> <option value="1">راهبر سيستم</option> <option v ...

Animating a group of images with JQuery

Hey there! I've been working on a simple animation for my webpage, but I'm having some trouble getting it to work the way I want. You can check out my page at . What I'm trying to achieve is having each image appear at its final position an ...

Managing post and session data during PHP form submission

I've encountered an issue with my code structure. What I aim to achieve is: To validate if post values exist, then execute the query and show the results. If post values are not present, check for a session value. If session is available, manipulate ...

Error message: "When namedPlaceHolder parameter is disabled, bind parameters must be in the form of an

Currently revamping my query due to a crucial API redesign. With the presence of a "file" as multipart/form-data, I found the need for a form handler since NextJS lacked one. After some workarounds with "multiparty", now I can successfully parse the incomi ...

Creative Vue.js and Tailwind CSS card layout featuring an image extending beyond the boundaries of the card

I'm attempting to design a card where an image pops out of the card. I've tried using z-index, but it doesn't seem to be working as expected. Here is the code I have: <div class="flex flex-col"> <div class=&quo ...

Is there a way to prevent Bootstrap 4's grid system from splitting column content when resizing the browser window?

Just delving into Bootstrap's grid system for the first time here, so bear with me if this sounds silly. My goal is to create a 3 column page that is responsive, featuring an image and a Spotify player in each column. Everything looks good on a full ...

Ensuring HTML is clean in SQL query using PHP function for sanitization

I am currently working on a PHP page that contains a dropdown form. When an option is selected, it triggers an AJAX script which queries a result from the same MySQL table. Overall, the functionality works as expected. However, I have encountered an issue ...

What is the best way to increase a numerical input?

While experimenting with HTML input elements, I decided to utilize the step attribute. This allowed me to increment the current value by 100 when clicking the up or down arrows in the input field. However, I discovered that the step attribute restricts th ...

An easy method for modifying data on a webpage hosted by an ESP8266 device

In my web page, I have a form to input times. The page is saved in flash memory and I want to update the times with previously stored values in EEPROM without loading the page into RAM. I prefer not to use websockets or AJAX for this purpose. I am looking ...

Troubleshooting problem with CSS alignment within Bootstrap framework

Having trouble with the alignment when using bootstrap CSS. My desired layout is as follows: Place name: dropdownbox Gender (radio-button)Male (radio-button)Female Amount Max: textbox Min: textbox Any advice on how to achieve this? ...

Examples of how to specify a child class in CSS

Presented here is the following structure: <article class="media media--small 48"> <a href="#"> <img src="" class="media__img" alt=""> <i class="s s--plus"></i></a> <div class="media__body"> < ...

Ellipsis malfunctioning in text overflow

It is known that the display type table-cell does not work with text-overflow ellipsis. However, this is where my issue lies. I am dealing with a file input control that appears like this: <div class="ui-select form-input" style="display:inline-block; ...

Buttons within the Bootstrap carousel caption cannot be clicked

I am currently designing a webpage with a Bootstrap carousel that includes a paragraph caption and two buttons. However, the buttons are not functioning as clickable links - when clicked, nothing happens. {% block body %} <div id ="car-container"> ...

Discovering the identification of a comment in JavaScript

Here is the code snippet I am working with: <a onclick="lel($(this),'212345555')" class="button"> <a onclick="lel($(this),'241214370')" class="button"> <a onclick="lel($(this),'248916550')" class="button"> & ...

Issue with JavaScript function loading website homepage solely is functioning only for the first time

I am in the process of creating my own personal website. To ensure seamless navigation, I added a "home" button that, when clicked, triggers a JavaScript function called loadhomepage() to load the homepage. While this function works perfectly upon initial ...

Customizing the appearance of the file input type using an image in HTML and CSS

Can you provide guidance on utilizing the image below? Is there an alternative approach to using: <input type="file" /> ...

Enhancing the appearance of a Textfield with PHP and HTML styling

How can I adjust the width and center text in a textfield within a container? <input type=text style=width:90%text-align:center value=" . $rows[mysql_field_name($sql_result, 3)] . "> Setting the width in the style attribute works when isolated like ...