css - last-child不起作用
問(wèn)題描述
<p style='display: block;'><table cellpadding='0' cellspacing='0'> <thead> <tr><th>任務(wù)執(zhí)行人</th><th>完成狀態(tài)</th><th>完成時(shí)間</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://www.cgvv.com.cn/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://www.cgvv.com.cn/wenda/@imgItem'/> </p> }}}</p> </p></p>}}} </p>
#taskContainer .operatorDetail:nth-last-child(1){ border-bottom:none;}
全選出了了啊 為什么啊
問(wèn)題解答
回答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 這種都是選擇同級(jí)別最后一個(gè)元素。但是看你的結(jié)構(gòu)是這樣的:
.clearfix>.operatorDetail.clearfix>.operatorDetail.clearfix>.operatorDetail
目標(biāo)元素 .operatorDetail 都沒(méi)有兄弟節(jié)點(diǎn),是唯一一個(gè),也就是全都是最后一個(gè)。所以就全被選中了。
回答2:因?yàn)閚th-last-child相對(duì)于的是父級(jí)標(biāo)簽的元素位置。
你的選擇器的意思就是選中所有clearfix下倒數(shù)第一個(gè)子元素,而且類(lèi)名是operatorDetail
相關(guān)文章:
1. python - 使用xlsxwriter寫(xiě)入Excel, 只能寫(xiě)入65536 無(wú)法繼續(xù)寫(xiě)入.2. Python做掃描,發(fā)包速度實(shí)在是太慢了,有優(yōu)化的方案嗎?3. objective-c - ios百度地圖定位問(wèn)題4. java - Web開(kāi)發(fā) - POI導(dǎo)出帶有下拉框的Excel和解決下拉中數(shù)組過(guò)多而產(chǎn)生的異常5. java - 微信退款,公賬號(hào)向個(gè)人轉(zhuǎn)賬SSL驗(yàn)證失敗6. java - 安卓接入微信登錄,onCreate不會(huì)執(zhí)行7. python - flask如何創(chuàng)建中文列名的數(shù)據(jù)表8. javascript - 關(guān)于定時(shí)器 與 防止連續(xù)點(diǎn)擊 問(wèn)題9. 微信開(kāi)放平臺(tái) - Android調(diào)用微信分享不顯示10. python - mysql 如何設(shè)置通用型字段? 比如像mongodb那樣
