php - 第一个 child 最后一个 child 和中间的 child

标签 php css css-selectors

好的,所以我从中获得了一个 PHP,该 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; }

最佳答案

#leftcolrightboxcheckattach:not(:first-child):not(:last-child)
{

      .....
}

关于php - 第一个 child 最后一个 child 和中间的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17297649/

相关文章:

php - 使用php preg_match(正则表达式)将camelCase单词拆分为单词

html - Div 网格单元格类型对齐

css - 使用 html5reset 复制 css 行

css - 用于选择除伪元素之外的所有元素的 LESS 嵌套规则

css - 选择特定 css 类的偶数行

javascript - Chart.js PHP 数据库数据不显示

php - 警告: Cannot modify header information - headers already sent by (two headers on one page?)

php - 在 DATETIME 列中存储日期和时间时遇到问题。 (使用 PHP 和 MySQL)

javascript - 基于使用指令的变量添加 css 类(或样式)

css - 在现有博客主题中使用 github-markdown-css