zoukankan      html  css  js  c++  java
  • CSS实现文字自动换行(兼容Firefox)

    CSS实现文字自动换行(兼容Firefox)

    大家都知道.文字在网页编写的时候是可以自动换行的.但是有一个让我们很头疼的就是英文往往是不能自动换行的.特别是连在一起的英文.有的时候我们会用CSS来限制表格的属性.比如OVERFLOW:HIDDEN,但这个属性不能很好的达到我们所要的目的.下面我们就来介绍用CSS实现文字换行的几种方法.供大家参考:


    对于div


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


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


    或者


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


    <div >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 >http://rzsq.sinaapp.com/</div>

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


    对于

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

    以下为引用的内容:

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


    <table width="80">
    <tr>
    <td>http://rzsq.sinaapp.com/</td>
    </tr>
    </table>






    效果:可以换行


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


    以下为引用的内容:

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


    <table width="80">
    <tr>
    <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    </tr>
    </table>





    效果:可以换行

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



    以下为引用的内容:

    <style>
    .tb{table-layout:fixed}
    </style>
    <table width=80>
    <tr>
    <td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
    </td>
    </tr>
    </table>

    效果:两个td均正常换行

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

    以下为引用的内容:

    <style>
    .tb {table-layout:fixed}
    .td {overflow:hidden;}
    </style> <table width=80>
    <tr>
    <td width=25% nowrap>
    <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
    </td>
    <td nowrap>
    <div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
    </td>
    </tr>
    </table>

    不在吃苦的年纪选择安逸!
  • 相关阅读:
    beforeEach的应用
    小程序
    betterScroll的应用
    前端规划
    vue中下载文件如pdf及图片
    vue cli3.x项目创建及配置
    python读取excel文件中所有sheet表格:openpyxl模块(二)
    python访问excel基本用法:openpyxl模块(一)
    SQL优化:设置执行计划的显示格式
    sql优化实战:把full join改为left join +union all(从5分钟降为10秒)
  • 原文地址:https://www.cnblogs.com/DaHai-st/p/6251167.html
Copyright © 2011-2022 走看看