ie6绝对居中彻底解决

代码:

css

.center {
    position: fixed;
    *position: fixed;
    _position: absolute;
    display: block;
    width: 700px;
    min-height: 80px;
    z-index: 998;
    background-color: #fff;
    border: 1px #d7d7d7 solid;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    -webkit-box-shadow: 0 5px 5px #d7d7d7;
    -moz-box-shadow: 0 5px 5px #d7d7d7;
    box-shadow: 0 5px 5px #d7d7d7;
    top: 50%;
    left: 50%;
    _top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight/2-this.offsetHeight/2-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
}

 js

   

高级浏览器ie8+,firefox,chrome,opera,safari
center.css({"margin-left": "-350px", "margin-top": (-1 * pos.height() / 2) + "px"});

 

ie6、7
center.css({"margin-left": (-1 * pos.width() / 2) + "px", "margin-top": (-1 * pos.height() / 2) + "px"});

 注:如果center宽度为百分比,照样适用,只是

高级浏览器ie8+,firefox,chrome,opera,safari
center.css({"margin-left": "center百分比宽度/2", "margin-top": (-1 * pos.height() / 2) + "px"});

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值