zoukankan      html  css  js  c++  java
  • table-layout:fixed 属性的解说

    table-layout:fixed 属性的解说
    如果想要一个table固定大小,里面的文字强制换行(尤其是在一长串英文文本,并且中间无空格分隔的情况下),以达到使过长的文字不撑破表格的目的,一般是使用样式:table-layout:fixed。但是在Firefox下面,会有一些问题:firefox下,内容会飘出框外,暂时没有找到解决办法

    例1:(IE浏览器)长串英文自动回行
    方法:同时加入word-wrap:break-word;

    table{table-layout:fixed;word-wrap:break-word;}

    例2:(IE浏览器)一个表格里的内容隐藏
    方法:使用样式table-layout:fixed与nowrap(一行一列)

    <style>
    .tbl {table-layout:fixed}
    </style>
    <table class="tbl" border=1 width=80>
    <tr>
    <td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td>
    </tr>
    </table>
    效果:

     


    width=80起作用了,换行也被干掉了。
     

    例3:(IEFirefox浏览器)固定宽度使多余内容隐藏
    方法:在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div (一行两列)


    <style>
    .tbl {table-layout:fixed}
    .td {overflow:hidden;}
    </style>
    <table class="tbl" border=1 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>

    效果:

     
     
  • 相关阅读:
    js中国标准时间转换成datetime格式
    elementUI合并单元格
    vue filter 过滤器
    typescript学习 回顾查漏
    vue 中使用 XLSX 和 xlsx-style 实现前端下载Excel表格
    git 删除本地分支以及远程分支
    linux 下 配置 nginx
    初涉gulp
    git remote prune origin删除本地有但在远程库已经不存在的分支
    js 加密和解密
  • 原文地址:https://www.cnblogs.com/donchen/p/4110196.html
Copyright © 2011-2022 走看看