css - last-child不起作用
问题描述
<p style='display: block;'><table cellpadding='0' cellspacing='0'> <thead> <tr><th>任务执行人</th><th>完成状态</th><th>完成时间</th> </tr> </thead> <tbody id='taskTableBody'> @{ var listExecution = Model.listtaskexecution; if (listExecution != null && listExecution.Count > 0) { foreach (var item in Model.listtaskexecution) { <tr><td>@(item.executbyname == null ? '' : item.executbyname)</td><td>@(item.executon == null ? '待完成' : '已完成')</td><td>@(item.executon)</td> </tr> } } } </tbody></table>@{if (Model.listtaskexecution != null && Model.listtaskexecution.Count > 0){foreach (var exectionItem in Model.listtaskexecution){<p style='margin-top:2rem; margin-bottom: 1em;'> <p class='operatorDetail'><p class='left operatorImg'> <img src='https://www.haobala.com/wenda/@exectionItem.avatar'></p><p class='left operatorContent'> <p class='operatorInfo'><h3> @exectionItem.executbyname</h3><p> @exectionItem.executon</p> </p> <p>@exectionItem.executiondescription</p>@{if (exectionItem.listimgurl != null && exectionItem.listimgurl.Count > 0){foreach (var imgItem in exectionItem.listimgurl){ <p class='itemImg left'><img src='https://www.haobala.com/wenda/@imgItem'/> </p> }}}</p> </p></p>}}} </p>
#taskContainer .operatorDetail:nth-last-child(1){ border-bottom:none;}
全选出了了啊 为什么啊
问题解答
回答1:The :nth-last-child(an+b) CSS pseudo-class matches an element that has an+b-1 siblings after it in the document tree, for a given positive or zero value for n, and has a parent element.
先看定义,nth 这种都是选择同级别最后一个元素。但是看你的结构是这样的:
.clearfix>.operatorDetail.clearfix>.operatorDetail.clearfix>.operatorDetail
目标元素 .operatorDetail 都没有兄弟节点,是唯一一个,也就是全都是最后一个。所以就全被选中了。
回答2:因为nth-last-child相对于的是父级标签的元素位置。
你的选择器的意思就是选中所有clearfix下倒数第一个子元素,而且类名是operatorDetail
相关文章:
1. css3 - 请问一下在移动端CSS布局布局中通常需要用到哪些元素,属性?2. PHP能实现百度网盘的自动化么?3. 网页爬虫 - python requests爬虫,如何post payload4. android - 使用vue.js进行原生开发如何进行Class绑定5. node.js - vue服务端渲染如何部署到线上6. node.js - 微信的自动回复问题7. MySQL 水平拆分之后,自动增长的ID有什么好的解决办法?8. javascript - 百度图片切换图片时url会改变,但无刷新,没用hash,IE8也支持,请问是用了什么技术?9. 我正在使用jsp / jstl / spring动态生成css和js。如何将此结果放置在头部的链接标签中。不在头部的脚本标签中10. angular.js - 各位大神们,你们混合开发,web方式中更推荐用什么框架呀? react?vue?angular?谢谢~
