first-child and last-child with IE8

前端 未结 3 1039
甜味超标
甜味超标 2020-12-08 02:06

I have some css for adjusting things in my table.

Here it is:

.editor td:first-child
{
    width: 150px; 
}

.editor td:last-child input,
.editor td         


        
3条回答
  •  猫巷女王i
    2020-12-08 02:39

    If your table is only 2 columns across, you can easily reach the second td with the adjacent sibling selector, which IE8 does support along with :first-child:

    .editor td:first-child
    {
        width: 150px; 
    }
    
    .editor td:first-child + td input,
    .editor td:first-child + td textarea
    {
        width: 500px;
        padding: 3px 5px 5px 5px;
        border: 1px solid #CCC; 
    }
    

    Otherwise, you'll have to use a JS selector library like jQuery, or manually add a class to the last td, as suggested by James Allardice.

提交回复
热议问题