手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >跨浏览器的CSS固定定位
跨浏览器的CSS固定定位
摘要:本文介绍了跨浏览器的CSS固定定位,请看下面的例子:……#fixed{position:fixed;top:5e...

本文介绍了跨浏览器的CSS固定定位,请看下面的例子:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

……

<style type="text/css">

#fixed{position:fixed;top:5em;right:0;……} /*针对IE7、Opera、Firefox一行搞定*/

</style>

/*IE6中利用容器对溢出内容的处理方式来实现的*/

<!–[if IE 6]>

<style type="text/css">

html{overflow:hidden;}

body{height:100%;overflow:auto;}

#fixed{position:absolute;right:17px;}

/*fixed元素的绝对位置是相对于HTML元素来说,滚动条是body元素的,这是设置right:17px的原因*/

</style>

<![endif]–>

<!–[if lt IE 6]>

<style type="text/css">

#fixed{position:absolute;top:expression(eval(document.body.scrollTop 50));}

</style>

<![endif]–>

</head>

<body>

<div id="wrapper">

……

</div>

<div id="fixed"><h2>{position:fixed}</h2></div>

</body>

</html>

【跨浏览器的CSS固定定位】相关文章:

兼容各浏览器:CSS定义PNG透明效果

web标准化设计环境中常用的CSS命名规则

巧用CSS来控制div自适应浏览器的高度

解决CSS浏览器兼容技巧

关于浏览器兼容性的讨论

火狐浏览器和IE的CSS区别

详解CSS的定位语法应用

css div绝对定位与固定定位实例

浅谈CSS编程的OOCSS和SMACSS设计模式

表格对决CSS

精品推荐
分类导航