CSS 位置固定在 IE 11 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29170622/
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
CSS Position Fixed Not Working in IE 11
提问by Ty Morton
I have an image gallery, with captions across the bottom (upper image). The captions use position:fixed; bottom:0;
, and works in every browser but IE, even the latest version (11.096…). The caption is fixed to the top of the screen, instead of the bottom (lower image).
我有一个图片库,底部有标题(上图)。字幕使用position:fixed; bottom:0;
, 并且适用于除 IE 之外的所有浏览器,甚至是最新版本 (11.096...)。标题固定在屏幕顶部,而不是底部(下图)。
I tried some of the suggestions I found while researching this on my own:
我尝试了我自己研究时发现的一些建议:
- Verified the correct doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- Added
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
- Added expressions to my CSS:
position:fixed; _position:absolute; bottom:0; _top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight);
- 验证了正确的文档类型:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- 添加
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
- 向我的 CSS 添加了表达式:
position:fixed; _position:absolute; bottom:0; _top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight);
What am I missing here?
我在这里缺少什么?
回答by Ciprian
Try using
position: expression(fixed);
Try using
position: relative;
on the parent element andposition: absolute;
on your caption. This is cross-browser.
尝试使用
position: expression(fixed);
尝试
position: relative;
在父元素和position: absolute;
标题上使用。这是跨浏览器。