What is the reason for Chrome not recognizing 'bottom: 0;' as a valid value for an absolutely positioned footer?

It seems like I may be facing a unique issue with my webpage layout in Chrome. The entire page is set up with absolutely positioned elements within a container that is relatively positioned. Although this setup is not typical, it was necessary for incorporating rotating images without using the CSS background property.

However, I have encountered an unexpected problem where the footer does not appear when positioned absolutely at bottom: 0; right: 0;

Here is the HTML structure:

<div id="wrapper">
  <div id="content">
  </div>
  <div id="footer">
    <ul>
    </ul>
  </div>
</div>

And here is the CSS styling:

#wrapper {
  position: relative;
  margin: 0 auto;
  width: 940px;
}

#content {
  position: absolute;
  top: 0;
  left: 0;
  height: 350px;
}

#footer {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 10;
}

Update: Due to future content being added dynamically on a WordPress site, the height of the wrapper cannot be predetermined. However, adjustments can be made to set the height of the footer element.

Answer №1

In case you are having trouble setting a height, consider removing the footer from the wrapper so it doesn't have a parent. The height of an absolutely positioned element is determined by its parent, and if the parent "wrapper" has no height, it will not align to the bottom.

Fortunately, the body will automatically go to the bottom.

You can find the code in this jsFiddles link.


#wrapper {
   position: relative;
   margin: 0 auto;
   width: 940px;
}

#content {
   background:#ccc; 
   position: absolute;
   top: 0;
   left: 0;
   height: 350px;
}

#footer {
   position: absolute;
   bottom: 0;
   right: 0;
   z-index: 10;
   background:papayawhip;
}

<div id="wrapper">
   <div id="content">
      sdfasdf
   </div>

</div>
<div id="footer">
   <ul>
      <li>aslfaskdjf</li>
   </ul>
</div>

Answer №2

When the height of #wrapper is set to 0px, the #footer appears but with a height of 0px as well. Check out this example where you can see that the #footer has a red border on the right side.

If you give the #wrapper a specific height and also apply a height to the #footer, take a look at how it displays in this demo. Alternatively, to make the footer match the height of its contents, simply remove its height property.

Answer №3

Indeed, the code above is correct. However, if your #wrapper has a relative position and your #footer is inside the #wrapper, the position of the #footer will be aligned according to the wrapper. If you set a height for the wrapper, it will become apparent. See below:

HTML:

<div id="wrapper">
  <div id="content">
  </div>
  <div id="footer">
    <ul>
your_content
    </ul>
  </div>
</div>

CSS:

#wrapper {
  position: relative;
  margin: 0 auto;
  height: 200px;
  width: 940px;
}

#content {
  position: absolute;
  top: 0;
  left: 0;
  height: 350px;
}

#footer {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 10;
}

You can view an example here http://jsfiddle.net/8DZ5R/

Alternatively, another way to solve this is by simply changing the position of "#footer" from "absolute" to "static". This means you don't need to adjust the height of the wrapper. You can see the updated version here http://jsfiddle.net/8DZ5R/1/

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

Could you please advise me on where I should apply line-height in order for it to work properly?

My div is structured like this: https://i.sstatic.net/3fUNs.png I am trying to decrease the spacing between the lines. I attempted adding a line-height attribute to both the parent div and one of the label elements like this: <div class="row" ...

Position elements flush to the left and right

Is it possible to align the text in divs so that it perfectly lines up along the edges? .name { margin: 0 0 5px 10px; font-weight: bold; font-size: 14px; } .row { margin: 0 0 5px 10px; width: 500px; justify-content: space-between; } < ...

Unusual syntax in Symfony framework

I am currently working on a new project for a website using the Symfony3 framework, and I have encountered an issue with understanding the syntax in Twig: <li><a href="{{ path('contact') }}">{{ 'site.template.menu.contact'| ...

Exploring Bootstrap's Product sample and attempting to understand the process of incorporating images

Currently, I am utilizing Bootstrap 4 and taking advantage of their Product example as a foundation: https://getbootstrap.com/docs/4.4/examples/product/ My goal is to transform the white and gray background sections into actual images of the product. The ...

Align the content of the list items to the center and position the list in the center of

I am struggling to get the List centered beneath "Contact Me" and the hr tag. Both of those elements are perfectly centered in the column, but the list and icons are aligned to the left. Ideally, I would like them to be in the center like everything else. ...

Utilize jQuery, Flash, or HTML5 to upload an image

Does anyone know of an upload tool or plugin that has a similar look and functionality to the one used on Codecanyon's website? I tried Uploadify, but it doesn't work on all browsers. I need something that is compatible with all browsers, whether ...

What is the method for eliminating the box shadow on a table?

Seeking assistance on removing the shadow effect from ng-tables upon hovering. Can someone guide me on how to achieve this? See screenshot here: http://prntscr.com/jcpl5g widget-body { background-color: #fbfbfb; -webkit-box-shadow: 1px 0 10px 1px rgba(0, ...

Preventing the elements within a div section from shifting position

I am facing an issue with a div section that contains multiple <a href=""> tags. When I shrink the div section on the page, the contents move when a user tabs into it. Is there a way to lock the div section so that its contents do not move? For exam ...

Function for editing a button in an AngularJS single page application

I am a beginner in AngularJS and I'm currently working on a project to create a single page application for tracking expenses. However, I'm facing some challenges with my code. Although I have successfully implemented most of the functions, I am ...

Divide text to reduce its width within the confines of a specific height on a div element

I've spent the past week scouring various forums, including stackoverflow, but I haven't been able to find a solution. In my responsive website, I'm using CSS flexbox to display dynamic menu items. Sometimes the text can be quite long, and ...

Enlarge the div with a click

I was looking for a solution on how to make a div expand when clicked using jQuery I came across a tutorial that seemed simple and perfect, but I couldn't get it to work when I tried to replicate the code. Do you know if this code is still valid wit ...

Introduction screen in a JQuery mobile application for Android devices

I'm currently working on an Android app that utilizes jQuery Mobile within my web-based application. I have multiple pages in the app and I am considering adding a splash screen to display when loading a new page or while the page is being loaded. Any ...

Ways to attach an item using its lower point instead of its upper coordinate

I am currently working on a poker table project using React. As of now, I have player components that need to be strategically positioned around the table. https://i.sstatic.net/gX9Ij.png One challenge I'm facing is that when the screen attribute ch ...

Excessive CPU/GPU usage caused by CSS transition animations

I am currently working on a small element on my website that involves a random size change in one of the DOM elements. const theDiv = document.getElementById("the-div"); function animate(){ const value = Math.floor(Math.random() * 200); theDiv.sty ...

Is the format of this HTML tag correct?

I was provided with a code from our design department to add to a page, and since I am relatively new to the design aspect of things, I'm seeking clarification. Is this a valid tag? Also, what does <--if subcontent add rel="test1"--> mean? The c ...

Linking two div elements together with a circular connector at the termination point of the line

I am currently working on designing a set of cards that will showcase a timeline. I envision these cards to be connected by lines with circles at each end, for a visually appealing effect. At the moment, I have created the cards themselves but I am struggl ...

Is it possible to visually distinguish the selected mat-grid-tile? Particularly when they are being created dynamically

On the user interface, I have a dynamic display of mat-grid-tile within a mat-grid-list. These tiles change in number and data based on backend values. When a user clicks on a mat-grid-tile, it triggers a function that receives the tile's data. My goa ...

Avoiding the repetition of CSS animations during Gatsby page hydration

I am facing an issue in Gatsby where I have an element with an initial CSS animation. It works perfectly when the static site loads, but after hydration, it keeps repeating. Is there a way to prevent this from happening? Below is my styled components code ...

Enhance the appearance of QTreeView items using a customized display delegate and CSS

In my QTreeView, I have a custom delegate set up for one of the columns to display a colored progress bar. The appearance of the progress bar depends on the content and I used the color information from option.palette to mimic the default delegate behavior ...

Steps for displaying a bootstrap modal in alignment with the triggering button's position

Recently diving into the world of bootstrap and AngularJs has been quite the learning experience for me. One challenge I encountered was trying to implement a bootstrap modal dialog box to show additional details within a table column. My goal was to hav ...