CSS css在页面底部放置一个元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8777649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:36:06  来源:igfitidea点击:

css position an element at the bottom of the page

csspositioning

提问by saomi

I need some tips about the best way to position one or more image at the bottom of the page or a container div. If possible css only.

我需要一些有关在页面底部或容器 div 中放置一个或多个图像的最佳方法的提示。如果可能,只有 css。

The only way I can accomplish that is using jquery :(

我可以完成的唯一方法是使用 jquery :(

回答by Wander Nauta

Try position: fixed. That will position any block element (div, image) at a fixed location with respect to the page. The element will stay there when you scroll (except on tablet/mobile devices). For example:

试试position: fixed。这会将任何块元素(div、图像)定位在相对于页面的固定位置。当您滚动时,该元素将留在那里(平板电脑/移动设备除外)。例如:

div#bottom {
  position: fixed;
  bottom: 0;

  /* And if you want the div to be full-width: */
  left: 0;
  right: 0;
}

回答by welldan97

you can use position: absolutefor it. Demo: http://jsfiddle.net/R2V4U/

你可以使用position: absolute它。演示:http: //jsfiddle.net/R2V4U/

回答by ChristopheCVB

#mydivid{
     position : fixed;
     bottom : 0;
}

would do the job.

会做的工作。