Implement colspan of table TD in external CSS

Source: Internet
Author: User

I personally feel that table layout is always troublesome.

There was a customer requirement a while ago.CodeRemove colspan = 3 from and define it in external CSS.

< Table Border = "2px" >
< Tr >
< TD Colspan = "3"   >
Table content
</ TD >
</ Tr >
< Tr >
< TD >
Table content
</ TD >
< TD >
Table content
</ TD >
< TD >
Table content
</ TD >
</ Tr >
</ Table >

 

Because the TD in CSS does not have the colspan attribute, It is a headache and cannot be implemented.

Finally, I fooled him with this method:

< Style Type = "Text/CSS" >
. Tdcolspan
{
Test : Expression (this. colspan = "3 ") ;
}
</ Style >
< Table Border = "2px" >
< Tr >
< TD Class = "Tdcolspan" >
Table content
</ TD >
</ Tr >
< Tr >
< TD >
Table content
</ TD >
< TD >
Table content
</ TD >
< TD >
Table content
</ TD >
</ Tr >
</ Table >

 

As shown in the Code, the CSS expression of IE can meet the following requirements:

 

However, note the following:

Expression can only be used in IE

Expressions are generally not used and consume a lot of resources.

 

 

 

 

 

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.