Use CSS to generate fine thin table table without complex style code

Source: Internet
Author: User

The exquisite table is the front-end development uses a component, many times we use the complex page style code, produces this kind of table, causes the page the modification and the readability are very poor. It is recommended to use CSS directly to produce a thin form.

The use method is also very simple:

First: Import Table.css

The

code is as follows:


<link rel= "stylesheet" type= "Text/css" href= "./css/table.css"/>


Second: Apply format

The

code is as follows:


<table class= "table" >


You only need to set the style class= "table" to the table, do not need to do any TR,TD operation. You can also write <table class= "table" style= "width:600px" > style= "width:600px" in order to control the width of the table more flexibly, If you write directly to the TABLE.CSS, there is no problem, if you want to let TD have background color, only need to set the TD's style class= "color" can be. Of course, you can use the expression in the CSS directly set to color interlacing, but that will reduce the efficiency of the page, do not recommend the use of expressions in CSS.

If you want to fine-tune the style, you just need to adjust the table.css, do not need to change any page HTML code. If you want to change the color of the border, find the color value in the TABLE.CSS: #ADD8E6, and then replace it all with the color value you want. The annex is a concrete example.

Table.css Source:

The

code is as follows:


/* Table style. */


. Table {


width:100%;


padding:0px;


margin:0px;


font-family:arial, Tahoma, Verdana, Sans-serif, XXFarEastFont-Arial;


border-left:1px solid #ADD8E6;


Border-collapse:collapse;


}


/* table header style. */


. Table th {


font-size:12px;


font-weight:600;


color: #303030;


border-right:1px solid #ADD8E6;


border-bottom:1px solid #ADD8E6;


border-top:1px solid #ADD8E6;


letter-spacing:2px;


Text-align:left;


padding:10px 0px 10px 0px;


Background:url (.. /images/tablehdbg.png);


White-space:nowrap;


Text-align:center;


Overflow:hidden;


}


/* cell style. */


. Table TD {


border-right:1px solid #ADD8E6;


border-bottom:1px solid #ADD8E6;


background: #fff;


font-size:12px;


padding:3px 3px 3px 6px;


Color: #303030;


Word-break:break-all;


Word-wrap:break-word;


White-space:normal;


}


/* Blue cell style, mainly used for interlacing colors. */


. Table td.color{


background: #edf7f9;


}


/* hyperlink style in table. */


. Table TD a:link{


font-weight:400;


color: #2259D7;


Text-decoration:none;


Word-break:break-all;


Word-wrap:break-word;


White-space:normal;


}


. Table TD a:visited {


font-weight:400;


color: #2259D7;


Text-decoration:none;


Word-break:break-all;


Word-wrap:break-word;


White-space:normal;


}


. Table TD a:hover {


font-weight:400;


Text-decoration:underline;


Color: #303030;


Word-break:break-all;


Word-wrap:break-word;


White-space:normal;


}


. Table TD a:active {


font-weight:400;


Text-decoration:none;


color: #2259D7;


Word-break:break-all;


Word-wrap:break-word;


White-space:normal;


}
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.