zoukankan      html  css  js  c++  java
  • IE6中文字溢出问题--多出一只猪

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
     4 <title>多了一只猪</title>
     5 </head>
     6 <body>
     7 <div style="400px">
     8 <div style="float:left"></div>
     9 <!-- -->
    10 <div style="float:right;400px">↓这就是多出来的那只猪</div>
    11 </div>
    12 </body>
    13 </html>

    1.IE6的BUG

    经测试,只有IE6中有文字溢出bug,ie7 8火狐正常。

    2.与浮动有关

    去除 <div style=”float:left”></div> 中的“float:left;”,你会发现多出来的“猪”字不见了,页面正常显示。同样去除 <div style=”float:right;400px”> 中的“float:right;”,多余的“猪”字也同样消失,页面正常显示。

    3.与注释“<---->”的位置有关

    将注释转移到 <div style=”float:left”></div> 前面,多余的“猪”字消失,页面正常显示。将注释转移到 <div style=”float:right;400px”> ↓这就是多出来的那只猪 </div> 下面,多余的“猪”字也同样消失,页面正常显示。

    4.与固定宽度有关

    去除 <div style=”float:right;400px”> 中的“400px”,多余的“猪”字消失,页面正常显示。

    5.溢出字数与注释条数有关

    增加注释的条数:当1条注释时,则多出来 1 个字;2 条注释时,则多出来 3 个字;3 条注释时,则多出来 5 个字……我们会从上面的规律中得到这样一个公式:溢出文字的字数=注释的条数 *2-1,这里的字数在中文或英文数字时都成立。当溢出的文字字数大于文本的字数时,文字区块将会消失。

    解决方法:

    a.不放置注释。最简单、最快捷的解决方法

    b.注释不要放置于 2 个浮动的区块之间

    c.将文字区块包含在新的 之间,如:<div style=”float:right;400px”><div> ↓这就是多出来的那只猪 </div> </div>

    d.去除文字区块的固定宽度,与 3 有相似之处

    高否?富否?帅否? 否? 滚去学习!
  • 相关阅读:
    86. Partition List
    328. Odd Even Linked List
    19. Remove Nth Node From End of List(移除倒数第N的结点, 快慢指针)
    24. Swap Nodes in Pairs
    2. Add Two Numbers(2个链表相加)
    92. Reverse Linked List II(链表部分反转)
    109. Convert Sorted List to Binary Search Tree
    138. Copy List with Random Pointer
    为Unity的新版ugui的Prefab生成预览图
    ArcEngine生成矩形缓冲区
  • 原文地址:https://www.cnblogs.com/baixc/p/3384071.html
Copyright © 2011-2022 走看看