CSS中的zoom:1的作用

兼容IE6、IE7、IE8浏览器,经常会遇到一些问题,可以使用zoom:1来解决,有如下作用:

触发IE浏览器的haslayout。解决ie下的浮动,margin重叠等一些问题。

比如,本站使用DIV做一行两列显示,HTML代码:

<div class="h_mainbox">
        <h2>推荐文章</h2>
        <ul class="mainlist">
            <li><a href="/html/2009-12-18/21-1907360304171.html" style="color:#0000FF" target="_blank">每天产生一个日志及日志按大小切割</a></li>
            <li><a href="/html/2009-11-12/21-932220455859.html" style="color:#0000FF" target="_blank">Memcached缓存读取添加与清空</a></li>
        </ul>
</div>

CSS代码:

.h_mainbox         
    { 
        border:1px solid #dadada; 
        padding:4px 15px; 
        background:url(../mainbox_bg.gif) 0 1px repeat-x; 
        margin-bottom:6px; overflow:hidden
    }
    .h_mainbox h2      { font-size:12px; height:30px; line-height:30px; border-bottom:1px solid #ccc; color:#555;}
    .h_mainbox h2 span { float:right; font-weight:normal;}
    .h_mainbox ul      { padding:6px 0px; background:#fff;}
    .mainlist          {overflow:auto; zoom:1;}
    .h_mainbox li
    { 
        width:268px; float:left; height:24px; 
        overflow:hidden; 
        background:url(../icon3.gif) 0 6px no-repeat; 
        padding:0px 5px 0px 18px; line-height:200%;
    }

.mainlist {overflow:auto; zoom:1;}的设置,就可以在IE6、IE7、IE8正常显示效果了。

另外:

用css中的zoom属性可以让网页实现IE7中的放大缩小功能。

比如你想让你的网页缩小为原来的一半,那么就在body中加入style="zoom:0.5",如:

 程序代码
<body style="zoom:0.5"> 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值