如何使DIV始终浮动在屏幕的右上角,以便即使当我向下滚动页面时,DIV仍然显示在相同的固定位置?谢谢。
发布于 2010-11-21 10:45:51
使用position: fixed,并将其锚定到页面的top和right端:
#fixed-div {
position: fixed;
top: 1em;
right: 1em;
}但是,IE6不支持position: fixed。如果您需要在IE6中使用此功能,this purely-CSS solution似乎可以做到这一点。您需要一个包装器<div>来包含一些样式才能工作,如stylesheet中所示。
发布于 2010-11-21 10:56:18
使用position:fixed,如前所述,IE6不能识别position:fixed,但是使用一些css魔法,您可以让IE6运行:
html, body {
height: 100%;
overflow:auto;
}
body #fixedElement {
position:fixed !important;
position: absolute; /*ie6 */
bottom: 0;
}!important标志使得你不必在IE中使用条件注释。这将使#fixedElement在除IE之外的所有浏览器中使用position:fixed,并且在IE中,position:absolute将与bottom:0一起生效。这将模拟IE6的position:fixed
https://stackoverflow.com/questions/4236151
复制相似问题