zoukankan      html  css  js  c++  java
  • html表格内容自动换行


    有时候表格会因为内容多少忽大忽小的很烦人,在网上搜了下解决方案,效果不错哦,给大家分享下!
    首先介绍两个利器:
    table-layout:fixed //固定表格大小
    word-break:break-all;//字符串自动换行
     
    注意:IE和firefox是有很大区别的!(我就是栽在这个上面了,⊙﹏⊙b汗)
    1. (IE浏览器)使用 table-layout:fixed;强制table的宽度,多余内容隐藏
    <table style="table-layout:fixed" width="200">
     
    2.(IE浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行
    <table width="200" style="table-layout:fixed;">
    <tr>
    <td width="25%" style="word-break : break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890
     
    3.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条
     
    4.(Firefox浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;无法起作用
    <table style="table-layout:fixed" width="200">
    <tr>
    <td width="25%" style="word-break : break-all; overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
  • 相关阅读:
    centos 7 配置 keepalived,主机高可用
    centos 7 安装 nginx
    windows10 设置虚拟网卡/ip
    c#程序以管理员权限运行
    关于js中属性那些事
    centos 7 问题集锦
    几个Git仓库开源软件的比较
    grpc proto3 初体验
    windows下maven安装配置(本地仓库配置)
    navicat premium patch/keygen instruction
  • 原文地址:https://www.cnblogs.com/grimm/p/5097895.html
Copyright © 2011-2022 走看看