Home  >  Article  >  Web Front-end  >  CSS: Detailed explanation of the role and use of the table-layout attribute

CSS: Detailed explanation of the role and use of the table-layout attribute

黄舟
黄舟Original
2017-06-30 13:33:241988browse

I have seen a lot of usage of CSS before, but I have not seen much about some properties that are not called less used. Today I was reading a post on Classic and found a discussion on the topic "How to use CSS to force TD not to wrap?" , I discovered the detailed explanation of the use of table-layout, and posted the content first:

Syntax:
table-layout: auto | fixed
Value:
auto:Default value. Default automatic algorithm. The layout will be based on the contents of each cell. The table will not be displayed until all contents in each cell are read and calculated.
fixed: Fixed layout algorithm. In this algorithm, the width of the table and columns depends on the sum of the widths of the col objects, or, if not specified, the width of each cell in the first row. If the table does not specify a width (width) attribute, the table is rendered with a default width of 100%.

Description:
Set or retrieve the layout algorithm of the table.
You can improve table rendering performance through this attribute. This property causes IE to render the table contents one row at a time thereby providing greater speed to information users. This property uses one of the following methods to arrange the table column width according to the following order:
Use the width (width) attribute information of the col or colGroup object.
Use the width (width) information of the cell in the first row of the table.
Divide the table width equally according to the number of table columns. regardless of the actual width of the table content.
If the content of the cell exceeds the column width, the content will be wrapped. If line wrapping is not possible, the content will be cropped. If this property is set to fixed, overflow can be used to control the handling of content that overflows the width of the cell (td). If the table row height is specified, then the wrapped content will be cropped vertically if it exceeds the specified table row height.
Set this attribute value to fixed to help improve table performance. The effect is especially significant for long tables.
Setting the table row height can further improve the rendering speed. The browser does not need to detect the content of each cell in the row to determine the row height before starting parsing and rendering.
This property is read-only for currentStyle objects. For other objects can be read and written.

The corresponding script attribute is tableLayout.

Note the following points:
1, you can improve table rendering performance through this attribute. This property causes IE to render the table contents one row at a time thereby providing greater speed to information users.
2. Set this attribute value to fixed to help improve table performance. The effect is especially significant for long tables.
3. Setting the table row height can further improve the rendering speed. The browser does not need to detect the content of each cell in the row to determine the row height before starting parsing and rendering.
------------------------------------------- -----
This feature is very useful for the speed and effect of long table display. Can be used to improve table performance!

The author's question is also quite interesting. The requirements are as follows:
1. In TD, do not have the nowrap attribute. You must find a way to put nowrap in CSS.
2. In TD, do not Line breaks are allowed, and the excess parts must be hidden!
Final implementation method (note that DTD cannot be added here, otherwise it cannot be implemented, I don’t know why):

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
.aa{
    table-layout : fixed;
}
td{
    overflow:hidden;
    height:22px;
}
</style>
</head>

<body>
<!--    var grid1=new JGrid(null,300);  
grid1.create();  var fldsList=new Array([&#39;bag&#39;,120],[&#39;name&#39;,200],[&#39;type&#39;,100]);  
grid1.createTitle(fldsList);  grid1.tackData("dataLayer")    //-->
<table class="aa" border="1" cellpadding="0" cellspacing="0" bordercolor="#F9F9F9" id="dataLayer">
  <colgroup>
  <col width="119" />
  <col width="199" />
  <col width="99" />
  </colgroup>
  <tbody>
    <tr basestyle="oRowLine2">
      <td>J2SE</td>
      <td>Java 2 Standard Edition </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>J2EE</td>
      <td>Java 2 Enterprise Edition </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>J2ME</td>
      <td>Java 2 Micro Edition </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>GPS</td>
      <td>Global Positioning System </td>
      <td>全球定位系统</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>CDMA</td>
      <td>Code Division Multiple Access </td>
      <td>码分多址</td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>SMS</td>
      <td>Short Message Service </td>
      <td>短信息服务</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>BREW</td>
      <td>Binary Runtime Environment for Wireless </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>Symbian</td>
      <td> </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>Windows Mobile Smartphone </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>MIDlet</td>
      <td> </td>
      <td>按MIDP规范开发的J2ME应用程序</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>MIDP</td>
      <td>Mobile Information Device Profile </td>
      <td>移动信息设备框架</td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>Profile</td>
      <td> </td>
      <td>框架/简表</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>CLDC</td>
      <td>Connected Limited Device Configuration </td>
      <td>标准配置</td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>CDC</td>
      <td>Connected Device Configuration </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>KVM</td>
      <td>K virtual Machine </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>SDK</td>
      <td>Software Development Kit </td>
      <td>软件开发工具包</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>JAR</td>
      <td>Java ARchive </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>JAD</td>
      <td>Java Application Descriptor </td>
      <td>应用程序描述符</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>GCF</td>
      <td>General Connection Framework </td>
      <td> </td>
    </tr>
    <tr basestyle="oRowLine1">
      <td>RMS</td>
      <td>Record Management System </td>
      <td>记录管理系统</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td>Sprite</td>
      <td> </td>
      <td>精灵</td>
    </tr>
    <tr basestyle="oRowLine1">
      <td> </td>
      <td> </td>
      <td>冲突检查</td>
    </tr>
    <tr basestyle="oRowLine2">
      <td> </td>
      <td> </td>
      <td>平铺图层</td>
    </tr>
  </tbody>
</table>
</body>
</html>


The above is the detailed content of CSS: Detailed explanation of the role and use of the table-layout attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn