HTML/CSS/Table Style/table column size — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:16, 26 мая 2010

Equal Content-sized Columns

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .auto-layout {
  table-layout: auto;
}
* .shrinkwrapped {
  width: auto;
}
* .p2 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<h2>Shrinkwrapped Table</h2> 
<table class="auto-layout shrinkwrapped"> 
    <tr> <td class="p2">2=50%</td> <td class="p2">50%</td></tr>
</table> 
</body>
</html>



Fixed Table and Undersized Columns

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
td {
  overflow: hidden;
}
* .fixed-layout {
  table-layout: fixed;
}

* .sized {
  width: 700px;
}
* .undersized {
  width: 18px;
  background: pink;
}
* .flex {
  width: auto;
  background: red;
}
</style>
</head>
<body>

<table class="fixed-layout sized"> 
    <tr> <td class="undersized">18px</td> <td class="flex">auto</td></tr>
</table> 

</body>
</html>



Percentage-proportioned Columns: 20%, 20%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .sized {
    table-layout: auto;
  width: 700px;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 80%;
  background: gold;
}
* .p3 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="sized"> 
    <tr> 
        <td class="p1">20%</td> 
        <td class="p1">20%</td>
    </tr>
</table> 

</body>
</html>



Percentage-proportioned Columns: 50%, 50%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .sized {
    table-layout: auto;
  width: 700px;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 80%;
  background: gold;
}
* .p3 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="sized"> 
    <tr> 
        <td class="p3">50%</td> 
        <td class="p3">50%</td>
    </tr>
</table> 

</body>
</html>



Percentage-proportioned Columns: 80%, 20%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .sized {
    table-layout: auto;
  width: 700px;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 80%;
  background: gold;
}
* .p3 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="sized"> 
    <tr> 
        <td class="p2">80%</td> 
        <td class="p1">20%</td>
    </tr>
</table> 

</body>
</html>



Percentage-proportioned Columns: 80%, 20%, 50%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .sized {
    table-layout: auto;
  width: 700px;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 80%;
  background: gold;
}
* .p3 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="sized"> 
    <tr> 
        <td class="p2">80%</td> 
        <td class="p1">20%</td> 
        <td class="p3">50%</td>
    </tr>
</table> 

</body>
</html>



Percentage-proportioned Columns: 80%, 80%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .sized {
    table-layout: auto;
  width: 700px;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 80%;
  background: gold;
}
* .p3 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="sized"> 
    <tr> 
        <td class="p2">80%</td> 
        <td class="p2">80%</td>
    </tr>
</table> 

</body>
</html>



Shrinkwrapped Table: 20%, 20%, 20%, 20%, 20%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .shrinkwrapped {
  table-layout: auto;
  width: auto;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="shrinkwrapped"> 
    <tr> 
        <td class="p1">20%</td> 
        <td class="p1">20%</td> 
        <td class="p1">20%</td> 
        <td class="p1">20%</td> 
        <td class="p1">20%</td>
    </tr>
</table> 

</body>
</html>



Shrinkwrapped Table: width auto, width 20%

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
* .shrinkwrapped {
  table-layout: auto;
  width: auto;
}
* .p1 {
  width: 20%;
  background: pink;
}
* .p2 {
  width: 50%;
  background: red;
}
</style>
</head>
<body>
<table class="shrinkwrapped"> 
    <tr> <td class="p1">20%</td></tr>
</table> 

</body>
</html>



Sized Table cannot be undersized

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
td {
  overflow: hidden;
}
* .auto-layout {
  table-layout: auto;
}

* .sized {
  width: 700px;
}
* .undersized {
  width: 18px;
  background: pink;
}
* .flex {
  width: auto;
  background: red;
}
</style>
</head>
<body>

<table class="auto-layout sized"> 
    <tr> <td class="undersized">18px</td> <td class="flex">auto</td></tr>
</table> 

</body>
</html>



stretched table with undersized column

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title></title>
<style type="text/css" media="Screen">
td {
  overflow: hidden;
}
* .stretched {
  width: 100%;
}

* .sized {
  width: 700px;
}
* .undersized {
  width: 18px;
  background: pink;
}
* .flex {
  width: auto;
  background: red;
}
</style>
</head>
<body>

<table class="stretched sized"> 
    <tr> <td class="undersized">18px</td> <td class="flex">auto</td></tr>
</table> 

</body>
</html>