Set the bottom to 100% of its own height
P粉098417223
P粉098417223 2024-04-04 22:41:16
0
1
1423

I want to set up an element so that it is hidden from the page view and its top just touches the bottom of the page (the element is out of view). When the height of the element is constant 66px, I first do botttom: -66px;' . But now I need this to handle elements of any size.

If I do bottom: -100%; it sets it to 100% of the parent's size. How can I set it to -100% of its own height.

P粉098417223
P粉098417223

reply all(1)
P粉005105443

You are looking for "position:fixed" and "transform:translateY(100%);". This allows you to move the div 100% out of the viewport, regardless of the div's height.

Example:

div {
  position: fixed;
  bottom: 0px;
  left: 0px;
  width: 100%;
  height: 40px;
  background-color: red;
  color: #fff;
  transform: translateY(100%);
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!