Set cellpadding and cellspacing in CSS?

前端 未结 28 1443
暖寄归人
暖寄归人 2020-11-22 02:15

In an HTML table, the cellpadding and cellspacing can be set like this:

28条回答
  •  一整个雨季
    2020-11-22 02:16

    This hack works for Internet Explorer 6 and later, Google Chrome, Firefox, and Opera:

    table {
        border-collapse: separate;
        border-spacing: 10px; /* cellspacing */
        *border-collapse: expression('separate', cellSpacing = '10px');
    }
    
    table td, table th {
        padding: 10px; /* cellpadding */
    }
    

    The * declaration is for Internet Explorer 6 and 7, and other browsers will properly ignore it.

    expression('separate', cellSpacing = '10px') returns 'separate', but both statements are run, as in JavaScript you can pass more arguments than expected and all of them will be evaluated.

提交回复
热议问题