css 兼容 position:fixed

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible"><!--据说这个可以只需要兼容IE7-->
<title>无标题文档</title>
<style type="text/css">
*{margin:0; padding:0; border:0;}

#d{
    background:url(images/index_bg.jpg) repeat-y scroll center top transparent;
    left: 50%;
    margin-left: -500px;
    position: relative;
    width: 1000px;
    }

.top,.main,.bottom,.fixed{text-align:center;}

.top{
    background-color:#C30;
    height: 101px;
    padding-top: 4px;
}

.main{
    width:980px;
    margin:20px auto 0;
    background-color:#FC0;
    padding:10px;
}
.main .cont{height:900px;}

.main .cont .contL,.main .cont .contR{
    float:left;
}

.main .cont .contL{
    width:750px;
    background-color:#93C;
    height:900px;
    margin-right:15px;
}

.main .cont .contR{
    width:210px;
    background-color:#33F;
    height:500px;
    }

.bottom{
    background-color:#00F;
    clear: both;
    color: #373737;
    height: 192px;
    margin: 10px auto;
    overflow: hidden;
    padding-top: 20px;
    width: 1000px;
}

.fixed{
    width:190px;
    line-height:40px;
    padding-top:20px;
    padding-bottom:20px;
    background-color:#999;
    position:fixed;
    left:65%;
    top:160px;
    z-index:999;/*为了让DIV永远在最前面,不被其他元素遮住*/
    _position:absolute;/*这里开始的2句代码是为ie6不兼容position:fixed;而写的*/
    _top:expression(eval(document.documentElement.scrollTop+160));/*这里需要获取滚动高度+元素原本的高度*/
}
</style>
</head>

<body>
    <div id="d">
        <div class="top">我是头</div>
        <div class="main">
        我是主体<br />
        有多少内容,我就有多高<br />
        <div class="cont">
            <div class="contL"></div>
            <div class="contR"></div>
        </div>
        </div>
        <div class="bottom">我是脚</div>
    </div>
    <div class="fixed">
    我要随滚动条滚动<br />
    我要随滚动条滚动<br />
    我要随滚动条滚动<br />
    </div>
</body>
</html>
时间: 2024-08-13 23:46:38

css 兼容 position:fixed的相关文章

小技巧css解决移动端ios不兼容position:fixed属性,无需插件

转载自:http://www.ithao123.cn/content-649841.html 移动端开发仿app头部底部固定设置position:fixed,android2.2以上已经实现.但是在ios8以下系统,当小键盘激活时,都会出现位置浮动问题.如图: 如何解决: 查阅资料之后想到一下几种解决方法 1,使用position:absolute模拟 <script type="text/javascript">     window.onscroll=function(

css解决移动端ios不兼容position:fixed属性,无需插件

移动端开发仿app头部底部固定设置position:fixed,android2.2以上已经实现.但是在ios8以下系统,当小键盘激活时,都会出现位置浮动问题.如图: 如何解决: 查阅资料之后想到一下几种解决方法 1,使用position:absolute模拟 <script type="text/javascript">     window.onscroll=function(){     $(".fixed").css("top"

css中position:fixed实现div居中

上下左右 居中 代码如下 复制代码 div{ position:fixed; margin:auto; left:0; right:0; top:0; bottom:0; width:200px; height:150px;} 如果只需要左右居中,那么把 bottom:0; 或者 top:0; 删掉即可如果只需要上下居中,那么把 left:0; 或者 right:0; 即可 下面附一个DIV 元素在浏览器窗口居中 其实,实现这个效果并不复杂,利用 CSS 中的 position 定位就可以轻松搞

css基础 position:fixed/absolute 把div转换为行内块元素

礼悟:    公恒学思合行悟,尊师重道存感恩.叶见寻根三返一,江河湖海同一体.          虚怀若谷良心主,愿行无悔给最苦.读书锻炼养身心,诚劝且行且珍惜.              ide:visual studio 2017             browser:Chrome                     os:win7 代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8&qu

CSS模拟position:fixed,一边滚动,一边不滚动

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

浏览器CSS兼容问题汇总及解决

由于公司项目要求兼容到IE6,这之中遇到不少CSS兼容性问题,所以就在博客汇总下来,以后在项目中遇到新的兼容性问题,也会在这里更新. 1.IE6下height属性会失效 问题描述:在IE6下,即使块级元素设置了高度,但若元素内部的内容超出设置高度,内部内容会把该块级元素高度撑开,height失效. 解决方法:对该块级元素设置overflow:hidden; 2.div存在最小高度 问题描述:在IE6下,块级元素会存在大概是13px默认最小高度,即使是空的div标签或者height属性设置比13p

用position:fixed编写超简单的固定footer

In this exercise you will create a sticku footer with is stuck at the bottom of the page allways. (固定在底部的footer) <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML CSS Exercise Create a sticky footer&l

CSS之Position全面认识

CSS的很多其他属性大多容易理解,比如字体,文本,背景等.有些CSS书籍也会对这些简单的属性进行大张旗鼓的介绍,而偏偏忽略了对一些难缠的属 性讲解,有避重就轻的嫌疑.CSS中主要难以理解的属性包括盒型结构,以及定位.正如positioniseverything,本文将主要讲述关于 position的理解,力求让您看完本文后对position有着最全面的认识. position的四个属性值 relative absolute fixed static 下面分别讲述这四个属性 复制代码 代码如下:

关于ie6 不支持position:fixed的问题

css中有position: fixed;可以直接用.IE6确不支持,解决办法: * html,* html body{background-image:url(about:blank);background-attachment:fixed;} .top-nav-wrap-fix{position: fixed; top:0; _position:absolute;_top:expression_r(eval_r(document.documentElement.scrollTop)); le