zoukankan      html  css  js  c++  java
  • CSS FireFox and IE 换行问题解决方案

    1
    /* 禁止换行 */

    .nowrap{word-break:keep-all;white-space:nowrap;}
    /* 强制换行 */
    .break{word-break:break-all;}

    css强制不换行
    div{white-space:nowrap;}

    css自动换行

    div{ word-wrap: break-word; word-break: normal; }

    css强制英文单词断行

    div{word-break:break-all;}

    大家都知道连续的英文或数字会把DIV或表格边框撑破,不能根据容器的大小自动换行,下面是 CSS如何将他们换行的方法!

    对于div

    1.(IE浏览器)white-space:normal; word-break:break-all;这里前者是遵循标准。

    #wrap{white-space:normal; 200px; }
    或者
    #wrap{word-break:break-all;200px;}

    eg.

    ddd1111111111111111111111111111111111111111111111111111111111111111111

     

    效果:可以实现换行

    2.(Firefox浏览器)white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法,只能隐藏或者加滚动条,当然不加滚动条效果更好!

    #wrap{white-space:normal; 200px; overflow:auto;}
    或者
    #wrap{word-break:break-all;200px; overflow:auto; }

    eg.

    ddd1111111111111111111111111111111111111111111111111111111111111111111

    效果:容器正常,内容隐藏

    对于table

    1. (IE浏览器)使用样式;
    eg.





    abcdefghigklmnopqrstuvwxyz 1234567890

     

    效果:可以换行

    2.(IE浏览器)使用样式与nowrap
    eg.





    abcdefghigklmnopqrstuvwxyz 1234567890

     

    效果:可以换行

    3. (IE浏览器)在使用百分比固定td大小情况下使用样式与nowrap

     






    abcdefghigklmnopqrstuvwxyz 1234567890 abcdefghigklmnopqrstuvwxyz 1234567890

     

    效果:两个td均正常换行

    3.(Firefox浏览器)在使用百分比固定td大小情况下使用样式与nowrap,并且使用div
    eg.







    abcdefghigklmnopqrstuvwxyz 1234567890

    abcdefghigklmnopqrstuvwxyz 1234567890

     

    这里单元格宽度一定要用百分比定义

    对于div,p等块级元素
    正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
    html

    正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义


    css
    #wrap{white-space:normal; 200px; }

    1.(IE浏览器)连续的英文字符和阿拉伯数字,使用word-wrap : break-word ;或者word-break:break-all;实现强制断行

    #wrap{word-break:break-all; 200px;}
    或者
    #wrap{word-wrap:break-word; 200px;}

    abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111



    效果:可以实现换行

    2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条


    #wrap{word-break:break-all; 200px; overflow:auto;}

    abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111



    效果:容器正常,内容隐藏

    对于table

    1. (IE浏览器)使用 ;强制table的宽度,多余内容隐藏





    abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss



    效果:隐藏多余内容

    2.(IE浏览器)使用 ;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行






    abcdefghigklmnopqrstuvwxyz 1234567890 abcdefghigklmnopqrstuvwxyz 1234567890



    效果:可以换行

    3. (IE浏览器)在td,th中嵌套div,p等采用上面提到的div,p的换行方法

    4. (Firefox浏览器)使用 ;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;无法起作用

  • 相关阅读:
    loadrunner(预测系统行为和性能的负载测试工具)
    SOA(面向服务的架构)
    Acunetix Web Vulnerability Scanner(WVS)(Acunetix网络漏洞扫描器)
    Redis主从复制
    Redis启动方式
    Struts2.5以上版本There is no Action mapped for namespace [/] and action name [userAction_login] associated with context path []
    使用Slf4j集成Log4j2构建项目日志系统的完美解决方案
    Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
    intellij 编译 springmvc+hibernate+spring+maven 找不到hbm.xml映射文件
    MySQL8连接数据库
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/2710513.html
Copyright © 2011-2022 走看看