css表达式的缺点,css 居中-css表达式及缺点

* html,* html body{background-image:url(about:blank);background-attachment:fixed;} //IE6下防抖动

.centerDiv { //居中

position: fixed !important;

left: 50%;

margin-left: -260px !important; //根据宽度修改

top: 50%;

margin-top: -200px !important;

_margin:0px;

_left: expression(eval(document.compatMode && document.compatMode==’CSS1Compat’)?(documentElement.scrollLeft + (document.documentElement.clientWidth-this.offsetWidth)/2):(document.body.scrollLeft + (document.body.clientWidth – this.clientWidth)/2));

_POSITION: absolute;

_TOP: expression(eval(document.compatMode && document.compatMode==’CSS1Compat’)?(documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2):(document.body.scrollTop + (document.body.clientHeight – this.clientHeight)/2));

}

.leftDiv{//固定左侧

position: fixed ; left: 0px; top: 150px;_position:absolute !important;_right:auto;_LEFT: expression(eval(document.compatMode && document.compatMode==\'CSS1Compat\')?(documentElement.scrollLeft + 0):(document.body.scrollLeft + 0)); _TOP: expression(eval(document.compatMode && document.compatMode=='CSS1Compat')?(documentElement.scrollTop + 150):(document.body.scrollTop + 150))

}

尽量避免使用CSS表达式

表达式的问题在于对其进行的求值的频率比人们期望的要高。他们不仅在页面呈现和大小改变时求值,当页面滚动甚至用户鼠标在页面上移过时都要求值。我们可以向CSS表达式中添加一个计数器来进行跟踪。

表达式计数器的实例:

转载时请注明出处及相应链接,本文永久地址:https://blog.yayuanzi.com/151.html

75d087ef9a9fb11dc373caaf33adbf7f.png

微信打赏

支付宝打赏

感谢您对作者terry的打赏,我们会更加努力!    如果您想成为作者,请点我

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值