Vlastnost rozložení tabulky CSS
Příklad
Nastavte různé algoritmy rozložení tabulky:
table.a {
table-layout: auto;
width: 180px;
}
table.b {
table-layout:
fixed;
width: 180px;
}
Definice a použití
Vlastnost table-layout
definuje algoritmus použitý k rozložení buněk, řádků a sloupců tabulky.
Tip: Hlavní výhoda rozložení tabulky: pevné; je, že se tabulka vykresluje mnohem rychleji. U velkých tabulek uživatelé neuvidí žádnou část tabulky, dokud prohlížeč nevykreslí celou tabulku. Pokud tedy použijete table-layout: fixed, uživatelé uvidí horní část tabulky, zatímco prohlížeč načte a vykreslí zbytek tabulky. To vyvolává dojem, že se stránka načítá mnohem rychleji!
Výchozí hodnota: | auto |
---|---|
Zděděno: | Ne |
Animovatelné: | Ne. Přečtěte si o tématu Animable |
Verze: | CSS2 |
Syntaxe JavaScriptu: | objekt .style.tableLayout="fixed" |
Podpora prohlížeče
Čísla v tabulce určují první verzi prohlížeče, která plně podporuje vlastnost.
Property | |||||
---|---|---|---|---|---|
table-layout | 14.0 | 5.0 | 1.0 | 1.0 | 7.0 |
Syntaxe CSS
table-layout: auto|fixed|initial|inherit;
Hodnoty vlastností
Value | Description | Play it |
---|---|---|
auto | Browsers use an automatic table layout algorithm. The column width is set by the widest unbreakable content in the cells. The content will dictate the layout | |
fixed | Sets a fixed table layout algorithm. The table and column widths are set by the widths of table and col or by the width of the first row of cells. Cells in other rows do not affect column widths. If no widths are present on the first row, the column widths are divided equally across the table, regardless of content inside the cells | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Související stránky
CSS tutoriál: CSS tabulka
Odkaz HTML DOM: vlastnost tableLayout