久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

:last-child 偽類與屬性選擇器混合不起作用

:last-child pseudo-class mixed with attribute selector not working(:last-child 偽類與屬性選擇器混合不起作用)
本文介紹了:last-child 偽類與屬性選擇器混合不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試選擇具有特定 data- 屬性的元素的第一個和最后一個子元素.

I'm trying to select the first and last child of an element with a specific data- attribute.

:first-child 選擇器工作正常,但 :last-child 不工作.我真的不知道是什么原因造成的.我檢查了錯別字.

The :first-child selector works fine, but :last-child isn't working. I seriously don't know what can cause this. I have checked for typos.

CSS

.element[data-type='element']:first-child {
    padding-left: 0;   
    background-color:red !important
}

.element[data-type='element']:last-child {
    padding-right: 0; 
    border-right:0; 
    background-color:red !important;
}

推薦答案

我正在嘗試選擇具有特定 data- 屬性的元素的第一個和最后一個子元素.

I'm trying to select the first and last child of an element with a specific data- attribute.

底線是,在 CSS 中沒有辦法做到這一點.

Bottom line is, there's no way to do that in CSS.

last-child(和 last-of-type)意思是,last child"和last child of type",它們確實是 不是的意思是最后一個孩子匹配整個選擇器,包括一個屬性選擇器".在您的情況下,第三個 div 實際上可能不是父元素中的最后一個子元素(或不是最后一個 div);除非您顯示整個 HTML,包括父元素及其所有子元素,否則無法判斷.

last-child (and last-of-type) mean, well, "last child", and "last child of type", they do not mean "last child matching the entire selector including an attribute selector". In your case, it is likely that the third div is not actually the last child (or not the last div) within the parent element; it's impossible to tell unless you show the entire HTML including the parent element and all its children.

這篇關于:last-child 偽類與屬性選擇器混合不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Style every third element?(每隔三個元素設置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 久久网一区二区三区 | 久久久久网站 | 黄网站在线播放 | 日韩视频在线播放 | 亚洲一区二区三区 | 久久久久久国产 | 好婷婷网 | 91av免费版 | 欧美在线天堂 | 狠狠操狠狠操 | av片网站 | 亚洲成人精品 | 在线播放第一页 | www.99re| 亚洲人在线| 夏同学福利网 | 岛国av免费在线观看 | 欧美自拍第一页 | 亚洲精品欧美 | 自拍偷拍在线视频 | av黄色网| 欧美一级黄色片 | 国产精品xxxx | 久国产视频| 亚洲精品一二三区 | 九九久久精品 | 日韩日韩日韩日韩日韩日韩日韩 | 日韩精品久久久久 | 国产精品美女视频 | 欧美久久久久久久久 | 亚洲精品在线91 | 国产精品精品3d动漫 | chengrenzaixian| 日韩欧美精品在线播放 | 国产高清视频在线观看 | 成人在线电影网站 | 日韩久久精品电影 | 91精品国产综合久久婷婷香蕉 | 精品一区二区三区在线观看国产 | 欧美日韩亚洲一区 | 久久国产精品一区二区三区 |