HTML/CSS/Table Style/table layout

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

Auto-layout Table with Flex 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;
}

* .sized {
  width: 700px;
}
* .flex {
  width: auto;
  background: gray;
}
* .sized1 {
  width: 200px;
  background: menu;
}
* .sized2 {
  width: 100px;
  background: gold;
}
* .sized3 {
  width: 500px;
  background:pink;
}
* .p1 {
  width: 20%;
  background: red;
}
</style>
</head>
<body>

<table class="auto-layout sized">
    <tr><td class="sized1">200px</td><td class="p1">20%</td><td class="sized2">100px</td> 
        <td class="flex">auto flex</td> <td class="flex">auto flex</td>
    </tr>
</table> 

</body>
</html>



Fixed Table with Flex 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">
* .fixed-layout {
  table-layout: fixed;
}

* .sized {
  width: 700px;
}
* .flex {
  width: auto;
  background: gray;
}
* .sized1 {
  width: 200px;
  background: menu;
}
* .sized2 {
  width: 100px;
  background: gold;
}
* .sized3 {
  width: 500px;
  background:pink;
}
* .p1 {
  width: 20%;
  background: red;
}
</style>
</head>
<body>

<table class="fixed-layout sized">
    <tr><td class="sized1">200px</td><td class="p1">20%</td><td class="sized2">100px</td> 
        <td class="flex">auto flex</td> <td class="flex">auto flex</td>
    </tr>
</table> 

</body>
</html>



Liquid Design in a Table

 
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitionalt//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Liquid Design in a Table</title>
    <style rel="stylesheet" type="text/css">
body {
  background-color: #efefef;
}
div#page {
  width: 95%;
  background-color: #ffffff;
  border-style: solid;
  border-width: 1px;
  border-color: #666666;
  padding: 20px;
  font-size: 12px;
}
</style>
  </head> 
  <body>
    <table width="95%" align="center">
      <tr>
        <td>
<h1>Sample Web Page</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eleifend, erat id commodo placerat, nulla purus bibendum justo, in dictum orci mi vitae nulla. Nullam semper viverra nulla. Sed lacinia feugiat eros. Maecenas ullamcorper ligula quis odio. Donec pede massa, pharetra sit amet, accumsan a, iaculis egestas, lectus. Etiam ullamcorper elementum wisi. Etiam et felis aliquet dui tempus sagittis. Donec dapibus ipsum id leo. Integer est ante, imperdiet non, suscipit sit amet, varius a, sem. Integer lobortis wisi id erat. Nullam aliquet augue ac elit. Nulla facilisi. Vivamus ligula tortor, molestie at, accumsan quis, semper vitae, augue. Praesent pede neque, sollicitudin non, facilisis sed, viverra a, pede. Cras nec urna. Curabitur ut metus. Curabitur erat lacus, tempus vitae, elementum nec, pulvinar vel, leo. Sed a velit. Proin erat. Donec sem. </p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eleifend, erat id commodo placerat, nulla purus bibendum justo, in dictum orci mi vitae nulla. Nullam semper viverra nulla. Sed lacinia feugiat eros. Maecenas ullamcorper ligula quis odio. Donec pede massa, pharetra sit amet, accumsan a, iaculis egestas, lectus. Etiam ullamcorper elementum wisi. Etiam et felis aliquet dui tempus sagittis. Donec dapibus ipsum id leo. Integer est ante, imperdiet non, suscipit sit amet, varius a, sem. Integer lobortis wisi id erat. Nullam aliquet augue ac elit. Nulla facilisi. Vivamus ligula tortor, molestie at, accumsan quis, semper vitae, augue. Praesent pede neque, sollicitudin non, facilisis sed, viverra a, pede. Cras nec urna. Curabitur ut metus. Curabitur erat lacus, tempus vitae, elementum nec, pulvinar vel, leo. Sed a velit. Proin erat. Donec sem. </p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eleifend, erat id commodo placerat, nulla purus bibendum justo, in dictum orci mi vitae nulla. Nullam semper viverra nulla. Sed lacinia feugiat eros. Maecenas ullamcorper ligula quis odio. Donec pede massa, pharetra sit amet, accumsan a, iaculis egestas, lectus. Etiam ullamcorper elementum wisi. Etiam et felis aliquet dui tempus sagittis. Donec dapibus ipsum id leo. Integer est ante, imperdiet non, suscipit sit amet, varius a, sem. Integer lobortis wisi id erat. Nullam aliquet augue ac elit. Nulla facilisi. Vivamus ligula tortor, molestie at, accumsan quis, semper vitae, augue. Praesent pede neque, sollicitudin non, facilisis sed, viverra a, pede. Cras nec urna. Curabitur ut metus. Curabitur erat lacus, tempus vitae, elementum nec, pulvinar vel, leo. Sed a velit. Proin erat. Donec sem. </p>
        </td>
      </tr>
    </table>
  </body>
</html>



Mixed Column Layouts and Fixed Table

 

<!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">
* .fixed-layout {
  table-layout: fixed;
}
* .stretched {
  width: 100%;
}
* .flex {
  width: auto;
  background: blue;
  
}
* .sized1 {
  width: 500px;
  background: gray;
}
* .sized2 {
  width: 200px;
  background: menu;
}
* .p1 {
  width: 80%;
  background: red;
}
* .p2 {
  width: 20%;
  background: yellow;
}
</style>
</head>
<body>
<table class="fixed-layout stretched"> 
    <tr>
        <td class="sized1">500px</td> 
        <td class="sized2">200px</td> 
        <td class="p1">80%</td> 
        <td class="p2">20%</td> 
        <td class="flex">auto</td>
    </tr>
</table> 

</body>
</html>



Mixed Column Layouts and stretched table

 

<!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;
}
* .stretched {
  width: 100%;
}
* .flex {
  width: auto;
  background: blue;
}
* .sized1 {
  width: 500px;
  background: gray;
}
* .sized2 {
  width: 200px;
  background: menu;
}
* .p1 {
  width: 10%;
  background: gold;
}
* .p3 {
  width: 40%;
  background: pink;
}
</style>
</head>
<body>
<table class="auto-layout stretched">
    <tr>
       <td class="sized1">500px</td> 
       <td class="sized2">200px</td> 
       <td class="p3">40%</td> 
       <td class="p1">10%</td> 
       <td class="flex">auto</td>
    </tr>
</table> 

</body>
</html>



Mixed Column Layouts with shrinkwrapped table

 

<!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;
}
* .flex {
  width: auto;
  background: blue;
}
* .sized1 {
  width: 500px;
  background: gray;
}
* .p1 {
  width: 10%;
  background: gold;
}
</style>
</head>
<body>
<table class="auto-layout shrinkwrapped">
    <tr>
       <td class="sized1">500px</td> 
       <td class="p1">10%</td> 
       <td class="flex">auto</td>
    </tr>
</table> 
</body>
</html>



Mixed Column Layouts with sized table

 

<!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;
}
* .sized {
  width: 700px;
}
* .flex {
  width: auto;
  background: blue;
}
* .sized1 {
  width: 500px;
  background: gray;
}
* .sized2 {
  width: 200px;
  background: menu;
}
* .p1 {
  width: 20%;
  background: yellow;
}
* .p2 {
  width: 80%;
  background: red;
}
</style>
</head>
<body>
<table class="auto-layout sized">
    <tr>
        <td class="sized1">500px</td> 
        <td class="sized2">200px</td> 
        <td class="p2">80%</td> 
        <td class="p1">20%</td> 
        <td class="flex">auto</td>
    </tr>
</table> 

</body>
</html>



Single Column Design with Table

 
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitionalt//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Single Column Design</title>
    <style rel="stylesheet" type="text/css">
body {
  background-color: #efefef;
  font-family: arial, verdana, sans-serif;
}
table {
  background-color: #ffffff;
  border-style: solid;
  border-width: 1px;
  border-color: #666666;
}
td {
  font-size: 12px;
}
.header {
  background-color: #f3f3f3;
  padding: 3px;
}
.nav {
  font-weight: bold;
  background-color: #e3e3e3;
  padding: 5px;
}
.content {
  padding: 10px;
}
</style>
  </head> 
  <body>
    <table width="700" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td class="header"><h1>My Company Name</h1></td>
      </tr>
      <tr>
        <td class="nav"><a href="">Home</a> | <a href="">Products</a> | <a href="">Services</a> | <a href="">About Us</a> | <a href="">Contact Us</a></td>
      </tr>
      <tr>
        <td class="content">
        <h2>Sample Web Page</h2>
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eleifend, erat id 
            commodo placerat, nulla purus bibendum justo, in dictum orci mi vitae nulla. Nullam 
            semper viverra nulla. Sed lacinia feugiat eros. Maecenas ullamcorper ligula quis 
            odio. Donec pede massa, pharetra sit amet, accumsan a, iaculis egestas, lectus. Etiam 
            ullamcorper elementum wisi. Etiam et felis aliquet dui tempus sagittis. Donec dapibus 
            ipsum id leo. Integer est ante, imperdiet non, suscipit sit amet, varius a, sem. 
            Integer lobortis wisi id erat. Nullam aliquet augue ac elit. Nulla facilisi. Vivamus 
            ligula tortor, molestie at, accumsan quis, semper vitae, augue. Praesent pede neque, 
            sollicitudin non, facilisis sed, viverra a, pede. Cras nec urna. Curabitur ut metus. 
            Curabitur erat lacus, tempus vitae, elementum nec, pulvinar vel, leo. Sed a velit. 
            Proin erat. Donec sem. </p>

        </td>
      </tr>
    </table>
  </body>
</html>



stretched Table with Flex 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">
* .stretched {
  width: 100%;
}
* .sized {
  width: 700px;
}
* .flex {
  width: auto;
  background: gray;
}
* .sized1 {
  width: 200px;
  background: menu;
}
* .sized2 {
  width: 100px;
  background: gold;
}
* .sized3 {
  width: 500px;
  background:pink;
}
* .p1 {
  width: 20%;
  background: red;
}
</style>
</head>
<body>

<table class="stretched sized">
    <tr><td class="sized1">200px</td><td class="p1">20%</td><td class="sized2">100px</td> 
        <td class="flex">auto flex</td> <td class="flex">auto flex</td>
    </tr>
</table> 

</body>
</html>



table-layout: default and width setting

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>table-layout</title>
        <style rel="stylesheet" type="text/css">
table {
    border: 1px solid rgb(200, 200, 200);
    caption-side: bottom;
    width: 200px;
}
th {
    background: lightyellow;
}
th, td {
    border: 1px solid rgb(200, 200, 200);
    padding: 5px;
}
col#album {
    width: 200px;
    background: pink;
    color: crimson;
}
col#released {
    width: 1%;
    background: gold;
}
div#control {
    width: 200px;
    background: crimson;
    color: white;
    text-align: center;
    font-family: monospace;
    margin-bottom: 5px;
    padding: 3px 0;
}        
        </style>
    </head>
    <body>
        <div id="control">
            &lt; -- 200 pixels -- &gt;
        </div>
        <table>
            <caption>
                My favorite records.
            </caption>
            <colgroup>
                <col id="album" />
                <col id="artist" />
                <col id="released" />
            </colgroup>
            <thead>
                <tr>
                    <th> album</th><th> artist</th><th> released</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> R</td><td> A</td><td> 1965</td>
                </tr>
                <tr>
                    <td> B</td><td> V</td><td> 1967</td>
                </tr>
                <tr>
                    <td> M</td><td> T</td><td> 1995</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>



table-layout: fixed

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>border-spacing</title>
        <style rel="stylesheet" type="text/css">
table {
    border: 1px solid rgb(200, 200, 200);
    width: 100%;
    table-layout: fixed;
    border-spacing: 0 15px;
}
th {
    background: lightyellow;
}
th, td {
    border: 1px solid rgb(200, 200, 200);
    padding: 5px;
    overflow: hidden;
}        
        </style>
    </head>
    <body>
        <table>
            <caption>
                My favorite records.
            </caption>
            <colgroup>
                <col/>
                <col/>
                <col/>
            </colgroup>
            <thead>
                <tr>
                    <th>album</th>
                    <th>artist</th>
                    <th>released</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> R</td>
                    <td> T</td>
                    <td> 1</td>
                </tr>
                <tr>
                    <td> B</td>
                    <td> V</td>
                    <td> 1</td>
                </tr>
                <tr>
                    <td> M</td>
                    <td> T</td>
                    <td> 1</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>



table-layout: fixed and width setting

 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>table-layout</title>
        <style rel="stylesheet" type="text/css">
table {
    border: 1px solid rgb(200, 200, 200);
    caption-side: bottom;
    width: 200px;
    table-layout: fixed;
}
th {
    background: lightyellow;
}
th, td {
    border: 1px solid rgb(200, 200, 200);
    padding: 5px;
}
col#album {
    width: 200px;
    background: rgb(244, 244, 244);
    color: crimson;
}
col#released {
    width: 1%;
    background: rgb(244, 244, 244);
}
div#control {
    width: 200px;
    background: crimson;
    color: white;
    text-align: center;
    font-family: monospace;
    margin-bottom: 5px;
    padding: 3px 0;
}        
        </style>
    </head>
    <body>
        <div id="control">
            &lt; -- 200 pixels -- &gt;
        </div>
        <table>
            <caption>
                My favorite records.
            </caption>
            <colgroup>
                <col/>
                <col/>
                <col/>
            </colgroup>
            <thead>
                <tr>
                    <th>album</th><th> artist</th><th> released</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> R</td><td> A</td><td> 1965</td>
                </tr>
                <tr>
                    <td> B</td><td> V</td><td> 1967</td>
                </tr>
                <tr>
                    <td> M</td><td> T</td><td> 1995</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>