当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > 跨浏览器的CSS固定定位

CSS样式表
CSS+DIV 拼图(26个英文字母)
css 模拟表格斜线
hr 样式实现1px直线
css 画的百度LOGO
css 文字上右下环绕广告的写法
CSS 实现未知内容高度的垂直水平居中(改良版)
input 按钮显示差异的解决方法
css 限定GridView宽度并加上滚动条
ie6 position-fixed效果
css 书写技巧 CSS 技巧教程
IE和FireFox JavaScript的函数名的作用域的异同
纯CSS 级联菜单实现代码
CSS 清除网页浮动 经验
id与class的使用原则 网页制作经验
CSS expression判断表达式设置input样式
应用IE6所不支持的CSS的type选择器
CSS 网页内容换行控制
DIV+CSS 网页布局心得
CSS 教程之内容设置的一些语法
用div和ul标签画表格进行布局兼容火狐、ie6、ie7、Opera等浏览器

CSS样式表 中的 跨浏览器的CSS固定定位


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 103 ::
收藏到网摘: n/a


本文介绍了跨浏览器的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>