php
  • css
  • css-selectors
  • 2013-06-25 86 views 1 likes 
    1

    好吧,所以我有一个PHP是由一个开关循环传播依赖于手头的动态情况(我认为)。现在,当我添加一个复选框时,我希望能够使第一个复选框在div中具有顶部边框和边,无底部。以下几个只有一个边框,最后一个有边和底部,但没有顶部。希望这是有道理的。这是我必须编辑的所有代码:第一个孩子的最后一个孩子和之间的

    case "E": 
        $str.='<div id="leftcolrightboxcheckattach"><div id="enqattachcheckcontent" ><div id="enqleftcolattachcheckbox"><input type="checkbox" id="answer_question_'.$row['ques_id'].'[]" name="answer_question_'.$row['ques_id'].'[]" value="'.$arrMul[$i]["mul_name"].'" style="border:thick solid #fff" /></div><div id="enqleftcolattachcheckboxright">'.$arrMul[$i]["mul_name"].'</div></div></div>'; 
        break; 
    

    这是我的CSS。标准类作品,last-child作品,但first-child不......有任何想法为什么?

    #leftcolrightboxcheckattach:first-child{width:96%; margin:5px auto; clear:both; background:#000; border-top:thin solid #E6E6E6; position:relative; } 
    #leftcolrightboxcheckattach{width:96%; margin:5px auto; clear:both; background:#fff; border-left:thin solid #E6E6E6; border-right:thin solid #E6E6E6; position:relative; } 
    #leftcolrightboxcheckattach:last-child{width:96%; margin:5px auto; clear:both; background:#fff; border-bottom:thin solid #E6E6E6; position:relative; } 
    
    +0

    因为你与中间规则覆盖它,把第一胎倒数第二胎。 – jcubic

    +0

    认为,但它没有任何区别的第一个孩子仍然是多余的。 – mrmason

    +0

    尝试使用像'body #leftcolrightboxcheckattach:first-child'这样的更窄的选择器' – jcubic

    回答

    0
    #leftcolrightboxcheckattach:not(:first-child):not(:last-child) 
    { 
    
         ..... 
    } 
    
    +0

    再次没有工作,是否会与开关有关 – mrmason

    相关问题