css - :nth-child(n)選擇器中的n可不可以引用到屬性中?
問(wèn)題描述
如果是原生的CSS(不使用編譯器)可不可以達(dá)到這樣的效果?或者有沒有哪個(gè)屬性或方法是可以使數(shù)值與n相關(guān)的?
.box:nth-child(n){ -webkit-animation-delay:n s; animation-delay:n s;}
問(wèn)題解答
回答1:在原生的基礎(chǔ)上,部分 Firefox 瀏覽器可以實(shí)現(xiàn) CSS 變量
element { --animation-delay: 3s;} .box:nth-child(n) {-webkit-animation-delay: var(--animation-delay);animation-delay: var(--animation-delay);}
詳情看 MDN 的文檔 https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables
回答2:不行nth-child(n) 中的n可以是an+b形式,或odd,even或數(shù)字,所以不應(yīng)該被作為變量使用你要實(shí)現(xiàn)的效果應(yīng)該用js實(shí)現(xiàn)或者可以使用一些支持變量的css預(yù)處理語(yǔ)言
相關(guān)文章:
1. boot2docker無(wú)法啟動(dòng)2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. docker-compose中volumes的問(wèn)題4. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.5. java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類6. nignx - docker內(nèi)nginx 80端口被占用7. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?8. dockerfile - 為什么docker容器啟動(dòng)不了?9. docker容器呢SSH為什么連不通呢?10. 關(guān)于docker下的nginx壓力測(cè)試

網(wǎng)公網(wǎng)安備