Share four great-looking, practical CSS style tables

Source: Internet
Author: User

1. Single-pixel border CSS table

This is a very common table style.


Source:

<!--CSS goes in the document HEAD or added to your external stylesheet--><style type= "Text/css" >table.gridta ble {font-family:verdana,arial,sans-serif;font-size:11px;color: #333333; Border-width:1px;border-color: #666666; Border-collapse:collapse;} table.gridtable th {border-width:1px;padding:8px;border-style:solid;border-color: #666666; Background-color: # Dedede;} Table.gridtable td {Border-width:1px;padding:8px;border-style:solid;border-color: #666666; Background-color: # FFFFFF;} </style><!--Table goes in the document BODY--><table class= "gridtable" ><tr><th>info Header 1</th><th>info Header 2</th><th>info header 3</th></tr><tr><td >text 1a</td><td>text 1b</td><td>text 1c</td></tr><tr><td>text 2a</td><td>text 2b</td><td>text 2c</td></tr></table>

2. CSS style table with background map

It's about the same as above, but there's more background in each lattice.

Cell-blue.jpg

Cell-grey.jpg

1. Download the above two images, named Cell-blue.jpg and Cell-grey.jpg

2. Copy the following code to where you want it, remember to modify the image URL

<!--CSS goes in the document HEAD or added to your external stylesheet--><style type= "Text/css" >table.imaget Able {font-family:verdana,arial,sans-serif;font-size:11px;color: #333333; Border-width:1px;border-color: #999999; Border-collapse:collapse;} table.imagetable th {background: #b5cfd2 url (' cell-blue.jpg '); border-width:1px;padding:8px;border-style:solid; Border-color: #999999;} Table.imagetable td {background: #dcddc0 url (' cell-grey.jpg '); border-width:1px;padding:8px;border-style:solid; Border-color: #999999;} </style><!--Table goes in the document BODY--><table class= "ImageTable" ><tr><th>info Header 1</th><th>info Header 2</th><th>info header 3</th></tr><tr><td >text 1a</td><td>text 1b</td><td>text 1c</td></tr><tr><td>text 2a</td><td>text 2b</td><td>text 2c</td></tr></table>

3. Auto-wrap the color of the CSS style table (need to use JS)

This CSS style table automatically switches the color of each row, which is useful when we need to update a large table frequently.


Code:

<!--Javascript goes in the document HEAD--><script type= "Text/javascript" >function altrows (ID) {if (  document.getElementsByTagName) {var table = document.getElementById (ID);  var rows = Table.getelementsbytagname ("tr"); for (i = 0; i < rows.length; i++) {if (i% 2 = = 0) {rows[i].classname = "Evenrowcolor";}      Else{rows[i].classname = "Oddrowcolor";} }}}window.onload=function () {altrows (' Alternatecolor ');} </script><!--CSS goes in the document HEAD or added to your external stylesheet--><style type= "Text/css" & gt;table.altrowstable {font-family:verdana,arial,sans-serif;font-size:11px;color: #333333; border-width:1px; Border-color: #a9c6c9; border-collapse:collapse;} table.altrowstable th {border-width:1px;padding:8px;border-style:solid;border-color: #a9c6c9;} Table.altrowstable td {Border-width:1px;padding:8px;border-style:solid;border-color: #a9c6c9;}. Oddrowcolor{background-color: #d4e3e5;}. Evenrowcolor{background-color: #c3dde0;} </style><! --Table goes in the document BODY--><table class= "altrowstable" id= "Alternatecolor" ><tr><th>info Header 1</th><th>info Header 2</th><th>info header 3</th></tr><tr><td >text 1a</td><td>text 1b</td><td>text 1c</td></tr><tr><td>text 2a</td><td>text 2b</td><td>text 2c</td></tr></tr><tr><td> Text 3a</td><td>text 3b</td><td>text 3c</td></tr><tr><td>text 4 A </td><td>text 4b</td><td>text 4c</td></tr><tr><td>text 5A</td ><td>text 5b</td><td>text 5c</td></tr></table><!--The table code can be Found Here:http://www.textfixer/resources/css-tables.php#css-table03--

4. Hover over the highlighted CSS style table (JS required)

Pure CSS display table highlighting in IE has a problem, so the use of JS to do this side of the highlight (because the CSDN blog limited the use of JS, I will be in the recent blog migration to their own web host).


One thing to be careful about is that you don't define the background color of the lattice.

<!--CSS goes in the document HEAD or added to your external stylesheet--><style type= "Text/css" >table.hovert Able {font-family:verdana,arial,sans-serif;font-size:11px;color: #333333; Border-width:1px;border-color: #999999; Border-collapse:collapse;} table.hovertable th {background-color: #c3dde0; Border-width:1px;padding:8px;border-style:solid;border-color: # A9C6C9;} table.hovertable TR {background-color: #d4e3e5;} Table.hovertable td {Border-width:1px;padding:8px;border-style:solid;border-color: #a9c6c9;} </style><!--Table goes in the document BODY--><table class= "hovertable" ><tr><th>info Header 1</th><th>info Header 2</th><th>info header 3</th></tr><tr onmouseover = "this.style.backgroundcolor= ' #ffff66 ';" onmouseout= "this.style.backgroundcolor= ' #d4e3e5 ';" ><td>item 1a</td><td>item 1b</td><td>item 1c</td></tr><tr onmouseover= "This.style.backgroundcolor= ' #ffff"onmouseout=" this.style.backgroundcolor= ' #d4e3e5 '; ><td>item 2a</td><td>item 2b</td><td>item 2c</td></tr><tr onmouseover= "this.style.backgroundcolor= ' #ffff66 ';" onmouseout= "this.style.backgroundcolor= ' #d4e3e5 ';" ><td>item 3a</td><td>item 3b</td><td>item 3c</td></tr><tr onmouseover= "this.style.backgroundcolor= ' #ffff66 ';" onmouseout= "this.style.backgroundcolor= ' #d4e3e5 ';" ><td>item 4a</td><td>item 4b</td><td>item 4c</td></tr><tr onmouseover= "this.style.backgroundcolor= ' #ffff66 ';" onmouseout= "this.style.backgroundcolor= ' #d4e3e5 ';" ><td>item 5a</td><td>item 5b</td><td>item 5c</td></tr></table>

A few of the most common CSS style tables are here, and we hope to help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.