• 解决文字撑大容器的方法,ie,ff, div,table


    对于div

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

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

    <div id=”wrap”>ddd1111111111111111111111111111111111</div>

    效果:可以实现换行

    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; }

    <div id=”wrap”>ddd3333333333333333333333333333333333333</div>

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

    对于table

    1. (IE浏览器)使用样式table-layout:fixed;

    <style>
    .tb{table-layout:fixed}
    </style>

    <table class=”tbl” width=”80″>
    <tr>
    <td>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    </tr>
    </table>

    效果:可以换行

    2.(IE浏览器)使用样式table-layout:fixed与nowrap

    <style>
    .tb {table-layout:fixed}
    </style>

    <table class=”tb” width=”80″>
    <tr>
    <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    </tr>
    </table>

    效果:可以换行

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

    <style>
    .tb{table-layout:fixed}
    </style>

    <table class=”tb” width=80>
    <tr>
    <td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    </tr>
    </table>

    效果:两个td均正常换行

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

    <style>
    .tb {table-layout:fixed}
    .td {overflow:hidden;}
    </style>

    <table class="tb" width=80>
    <tr>
    <td width=25% class="td" nowrap>
    <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
    </td>
    <td class="td" nowrap>
    <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
    </td>
    </tr>
    </table>

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

    效果:正常显示,但不能换行(注:在FF下还没有能使容器内容换行的好方法,只能用overflow将多出的内容隐藏,以免影响整体效果)
    CSS样式解决英文换行断词问题

    * {word-wrap : break-word ;word-break : break-all ;}
    /*word-wrap是控制换行的。
    使用break-word时,是将强制换行。中文没有任何问题,英文语句也没问题。但是对于长串的英文,就不起作用。
    break-word是控制是否断词的。
    normal是默认情况,英文单词不被拆开。
    break-all,是断开单词。在单词到边界时,下个字母自动到下一行。主要解决了长串英文的问题。
    keep-all,是指Chinese, Japanese, and Korean不断词。即只用此时,不用word-wrap,中文就不会换行了。(英文语句正常。)
    ie下:
    使用word-wrap:break-word;所有的都正常。

  • 相关阅读:
    压缩感知的由来
    VS2010自动崩溃问题
    随机过程好书推荐
    Kernel PCA
    稀疏性与L1范数
    豆瓣关于计算机视觉的书评及介绍
    压缩感知测量矩阵的研究现状(转)
    信号的功率谱、能量谱、频谱的区别(转)
    vc++ & matlab 换行符号
    arg min 的含义
  • 原文地址:https://www.cnblogs.com/natureclove/p/pagefour.html
Copyright © 2020-2023  润新知