css3 position fixed固定居中问题解决方案
通常,我们要让某元素居中,会这样做:
#element{
margin:0 auto;
}
如果还想让此元素位置固定呢?一般我们会添加position:fixed,如下:
#element{
position:fixed;
margin:0 auto;
}
但是这样做的结果就是,元素不居中了。这说明fixed使对象脱离了正常文档流。
解决方案:
#element{
position:fixed;
margin:0 auto;
left:0;
right:0;
}
但是在ie7以下的版本中无法工作,要将其更改为:
#element{
position:fixed;
margin:0 auto;
left:auto;
right:auto;
}
最后我们可以这样:
if ($.browser.msie && parseint($.browser.version, 10) <= 7) {
stralertwrapper.css({position:'fixed', bottom:'0', height:'auto', left:'auto', right:'auto'});
}
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
CSS基础及用法
前言对于一个网页来说,css是网页的门面,对于一个前端初学者来说,css更是他们必经之路,通过这篇文章我就来带大...
[阅读全文]
-
-
-
-
-
网友评论