西安力洋网站建设

西安力洋网络
  • CSS技巧:关于CSS Hack与float闭合

  • 发布者:本站 发布时间:2010/3/1 11:30:24
  • 一、CSS HACK

    以下两种方法几乎能解决现今所有HACK。

    1、 !important

    随着IE7对!important的支持,!important 方法现在只针对IE6的HACK。(注意写法:记得该声明位置需要提前。)

    <style>
    #wrapper
    {
    width: 100px!important;
    width: 80px;
    }
    </style>

    2、IE6/IE77对FireFox

    *+html 与 *html 是IE特有的标签,firefox 暂不支持。而*+html 又为 IE7特有标签。

    <style>
    #wrapper
    {
    #wrapper { width: 120px; }
    *html #wrapper { width: 80px;}
    *+html #wrapper { width: 60px;}
    }
    </style>

    注意:

    *+html 对IE7的HACK 必须保证HTML顶部有如下声明:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

    二、float 闭合(清除浮动)

    将以下代码加入Global CSS 中,给需要闭合的div加上 class="clearfix" 即可,屡试不爽。

    <style>
    .clearfix:after
    {
    content:".";
    display:block;
    height:0;
    clear:both;
    visibility:hidden;
    }
    .clearfix
    {
    display:inline-block;
    }
    .clearfix {display:block;}
    </style>

  • 返回列表
    相关阅读
    更多
    深度挖掘网站的商用价值,化繁为简的设计,为企业找到直接有效的解决方案
    +86 (029) 88765320
    +86 15829904657
    地址:西安市太华北路369号
    万达广场4#23F P.C:7100001
    boss@178365.net
    在线咨询: 985224206
    互联网协会成员单位
    西安力洋之星网络技术有限公司 | 版权所有
    Copyright 2008-2020 Liyang.Inc All Rights Reserved.
    Liyang.Inc