<!doctype html>
<html>
<head>
<style>
.fr{float:right;display:inline}
li{border:1px solid #ccc;width:150px;height:18px}
li img{width:16px;height:16px}
ul{widht:100%;height:100%}
</style>
</head>
<body>
<ul><li>哈哈<img class='fr' src='aaa.gif'></li><ul>
</body>
</html>

上述代码的 目的 是让 图片在Li内部靠右浮动,在ie8+ ,以及chrome 之类的浏览器均正常,但在ie7 - 之下 不正常,第一个想到的就是浮动闭合问题

于是修改成

 <!doctype html>
<html>
<head>
<style>
.fr{float:right;display:inline}
li{border:1px solid #ccc;width:150px;height:18px}
li img{width:16px;height:16px}
ul{widht:100%;height:100%} .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
.clearfix{*zoom:1;}
</style>
</head>
<body>
<ul><li class='clearfix'>哈哈<img class='fr' src='aaa.gif'></li><ul>
</body>
</html>

发现效果未变,还是那个图被挤在li下方

最终再几经测试之后,终于明白 应该把那个文字也要进行浮动,但为什么文字也需要浮动 还是没有具体想明白,有清楚的兄弟告诉我一下,具体代码如下

  <!doctype html>
<html>
<head>
<style>
.fr{float:right;display:inline}
.fl{float:left;display:inline}
li{border:1px solid #ccc;width:150px;height:18px}
li img{width:16px;height:16px}
ul{widht:100%;height:100%} .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
.clearfix{*zoom:1;}
</style>
</head>
<body>
<ul><li class='clearfix'><span class='fl'>哈哈</span><img class='fr' src='aaa.gif'></li><ul>
</body>
</html>

参考

《哪些年我们一起清除过的浮动》http://www.iyunlu.com/view/css-xhtml/55.html

ie7 用 clearfix 清除浮动时遇到的问题的更多相关文章

  1. css用clearfix清除浮动

    本文从http://www.studyofnet.com/news/196.html复制.   本文导读:写css 时总为浮动而烦恼,如果用了浮动,浮动的父层不会跟着浮动框的高度增加而增加,在Fire ...

  2. clearfix清除浮动

    首先在很多很多年以前我们常用的清除浮动是这样的. 1 .clear{clear:both;line-height:0;} 现在可能还可以在很多老的站点上可以看到这样的代码,相当暴力有效的解决浮动的问题 ...

  3. clearfix清除浮动进化史

    我想大家在写CSS的时候应该都对清除浮动的用法深有体会,今天我们就还讨论下clearfix的进化史吧. clearfix清除浮动 首先在很多很多年以前我们常用的清除浮动是这样的. .clear{cle ...

  4. [笔记]使用clearfix清除浮动

    转载自奶牛博客 .clearfix { *zoom: 1; } .clearfix:before, .clearfix:after { display: table; line-height: 0; ...

  5. clear-fix清除浮动的两种写法

    1. [代码]clearfix 清除浮动 .clearfix:after { content: "."; display: block; height: 0; font-size: ...

  6. css中clearfix清除浮动的用法及其原理示例介绍

    clearfix的定义: .clearfix:after {}{ content: "."; /**//*内容为“.”就是一个英文的句号而已.也可以不写.*/ display: b ...

  7. clearfix 清除浮动的问题

    今天看一篇博文,发现其实有很多方法实现清除浮动,各有利弊 采用伪类:after进行后续空制的高度位零的伪类层清除 采用CSS overflow:auto的方式撑高 采用CSS overflow:hid ...

  8. CSS - clearfix清除浮动

    首先,我们来解释一下为什么要使用 clearfix(清除浮动). 通常我们在写html+css的时候,如果一个父级元素内部的子元素是浮动的(float),那么常会发生父元素不能被子元素正常撑开的情况, ...

  9. .clearfix 清除浮动,@import

    我们知道,在网页的DIV+CSS布局中,很多时候要用到浮动. 既然有浮动,那就有清除浮动. 清除浮动有很多种方式,而在实际项目中,比较常用的是这一种. .clearfix:after { conten ...

随机推荐

  1. Linux Oracle 转换编码格式

    [oracle@gpdb ~]$ sqlplus /nolog SQL> conn /as sysdba; SQL>select userenv('language') from dual ...

  2. Nginx中rewrite实现二级域名、三级域名、泛域名、路径的重写

    最常见的: 静态地址重定向到带参数的动态地址 rewrite "^(.*)/service/(.*)\.html$" $1/service.php?sid=$2 permanent ...

  3. js_多个引号的用法

    str += "<input id='sel_DayB' width='120' onfocus=\"WdatePicker({skin:'whyGreen',dateFmt ...

  4. Table样式

    .tb_org th { background-color: #; color: #ffffff; } .tb_org { border-right: 1px solid silver; border ...

  5. 【oracle】oracle学习笔记2--scoot账户的激活与解锁

    1.用sysz账户as sysddba登录,并执行scott.sql文件.我的文件目录是C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin ...

  6. 两主机搭建MySQL主从复制后,show slave status显示:Last_IO_Error: error connecting to master ……

    两台主机A.B搭建mysql主从复制关系(A为master,B为slave)后,在slave上执行show slave status,结果中显示Last_IO_Error: error connect ...

  7. zookeeper能做什么?

    Zookeeper是Hadoop的一个子项目,虽然源自hadoop,但是我发现zookeeper脱离hadoop的范畴开发分布式框架的运用越来越多.今天我想谈谈zookeeper,本文不谈如何使用zo ...

  8. SSH连接超时不自动断开

    Putty 启用putty keepalive putty -> Connection -> Seconds between keepalives ( 0 to turn off ),默认 ...

  9. 总结oninput、onchange与onpropertychange事件的用法和区别,onchange

    前端页面开发的很多情况下都需要实时监听文本框输入,比如腾讯微博编写140字的微博时输入框hu9i动态显示还可以输入的字数.过去一般都使用onchange/onkeyup/onkeypress/onke ...

  10. linux查找进程,查找僵死进程,查找僵死进程并自动杀掉

    查找进程: ps -aux | grep  flume  /  netstat -anop | grep 8080(端口号) 常规杀进程: kill  pid 查看僵死进程: ps -A -o sta ...