zoukankan      html  css  js  c++  java
  • html自动换行

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

    css

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


    或者

    效果:可以实现换行

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

     

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

    对于table

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

     


    abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss


    效果:隐藏多余内容

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

     





    效果:可以换行

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

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

     







    效果:隐藏多于内容

    5.(Firefox浏览器) 在td,th中嵌套div,p等采用上面提到的对付Firefox的方法
    运行代码框
    最后,这种现象出现的几率很小,但是不能排除网友的恶搞。如果有什么问题请到我的留言本提出

    下面是提到的例子的效果

    div

    All white-space:normal;

    Wordwrap still occurs in a td element that has its WIDTH attribute set to a value smaller than the unwrapped content of the cell, even if the noWrap property is set to true. Therefore, the WIDTH attribute takes precedence over the noWrap property in this scenario

    IE word-wrap : break-word ;

    abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111

    IE word-break:break-all;

    abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111

    Firefox/ word-break:break-all; overflow:auto;

    abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111

    table

    table-layout:fixed;

     
    abcdefghigklmnopqrstuvwxyz 1234567890
    abcdefghigklmnopqrstuvwxyz 1234567890
    abcdefghigklmnopqrstuvwxyz1234567890 abcdefghigklmnopqrstuvwxyz1234567890
    abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss

    table-layout:fixed; word-break : break-all; word-wrap : break-word ;

    abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss

    FF table-layout:fixed; overflow:hidden;

    abcdefghigklmnopqrstuvwxyz1234567890 abcdefghigklmnopqrstuvwxyz1234567890
  • 相关阅读:
    第一个mpvue小程序开发总结
    ES6学习笔记(一)——扩展运算符和解构赋值
    我所理解的发布订阅模式
    移动web开发适配方案之Rem
    探究JS中对象的深拷贝和浅拷贝
    《BAT前端进阶[师徒班]》学习总结
    浅析使用vue-router实现前端路由的两种方式
    webpack之proxyTable设置跨域
    《免费前端教程不会告诉你这些》知乎LIVE读后感
    MySQL binlog-server搭建
  • 原文地址:https://www.cnblogs.com/howie/p/3166416.html
Copyright © 2011-2022 走看看