您的位置:首页 > Web前端 > CSS

关于CSS在浏览器中固定定位position:fixed的应用

2008-12-24 17:33 816 查看
对于样式position:fixed,IE7及大多数浏览器都有用,而对于IE6及以下版本,并不能应用!
对于页面固定标签<div id="top">
<a href="#top11" title="回到页眉">回到页眉</a></div>的应用。
IE7及其他浏览起可以这样设置样式:
<style type="text/css">
#top{position:fixed; bottom:0;right:0;height:34px;width:34px;}
#top a{display:block;height:35px;width:35px;text-indent:-9999px;background:url(http://dancewithnet.com/wp-content/themes/dancewithnet/img/symbols.png) no-repeat 0 -600px;}
#top a:hover{border:none;background:url(http://dancewithnet.com/wp-content/themes/dancewithnet/img/symbols.png) no-repeat 0 -635px;}
</style>
而对于IE6浏览器的兼容需要加上声明:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
及样式:
<style type="text/css">
html{overflow:hidden;}
body{height:100%;overflow:auto;}
#top{position:absolute;right:17px;}
</style>
这样就是实现绝大部分浏览器兼容(不包括IE5以下)
本文出自 “脱发吃什么 www.faako.com” 博客,请务必保留此出处http://opper.blog.51cto.com/628423/122271
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: