css在页面底部定位一个元素

sao*_*omi 6 css positioning

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

我能做到的唯一方法就是使用jquery :(

Wan*_*uta 15

试试position: fixed.这将把任何块元素(div,image)定位在相对于页面的固定位置.滚动时元素将保留在那里(平板电脑/移动设备除外).例如:

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

  /* And if you want the div to be full-width: */
  left: 0;
  right: 0;
}
Run Code Online (Sandbox Code Playgroud)

  • 当我说页面底部时,我指的是文档底部,而不是窗口浏览器底部。当我加载页面时,图像不可见,但是当我向下滚动到最后时,我可以看到它。你明白了吗?? (3认同)
  • 那么你可能正在寻找 `position: absolute`。 (2认同)

Chr*_*CVB -1

#mydivid{
     position : fixed;
     bottom : 0;
}
Run Code Online (Sandbox Code Playgroud)

会做的工作。