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='http://m.piao2010.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='http://m.piao2010.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. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????2. 在應用配置文件 app.php 中找不到’route_check_cache’配置項3. html按鍵開關如何提交我想需要的值到數據庫4. css - width設置為100%之后列表無法居中5. ios - vue-cli開發項目webstrom會在stylus樣式報錯,飆紅,請大神幫忙6. javascript - 一個頁面有四個圖片,翻頁的時候想固定住某個圖片然后翻頁,如何實現呢?7. css3 - 怎么感覺用 rem 開發的不多啊8. html5 - 用Egret寫的小游戲,怎么分享到微信呢?9. python - 在pyqt中做微信的機器人,要在表格中顯示微信好友的名字,卻顯示不出來,怎么解決?10. objective-c - 自定義導航條為類似美團的搜索欄樣式
