CSS裡面能用odd。在CSS中,odd可以在偽類選擇器中作為關鍵字選取指定元素,常作為「:nth-child()」選擇器的參數,用於選取父元素中奇數行的指定子元素,語法「指定子元素:nth-child(odd){//css樣式}」。
本教學操作環境:windows7系統、CSS3&&HTML5版、Dell G3電腦。
CSS裡面能用odd。
odd的意思為“奇數”,在CSS中,可以在偽類選擇器中作為關鍵字選取指定元素。
odd常與「:nth-child(n)」選擇器搭配使用,作為此選擇器的參數,用於選取父元素中奇數行的指定子元素
指定子元素:nth-child(odd){//css样式}
說明:相對於odd,還有一個關鍵字even(偶數),和「:nth-child(n)」選擇器搭配使用,可選取父元素中偶數行的指定子元素
範例:實作表格的隔行變色
即奇數行一個顏色,偶數行一個顏色
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> tr:nth-of-type(even){ background:red; } tr:nth-of-type(odd){ background:pink; } </style> </head> <body> <table border="1"> <tr> <th>商品</th> <th>价格</th> </tr> <tr> <td>T恤</td> <td>¥100</td> </tr> <tr> <td>牛仔褂</td> <td>¥250</td> </tr> <tr> <td>牛仔库</td> <td>¥150</td> </tr> </table> </body> </html>
擴充知識:
:nth-child(n)
選擇器符合父元素中的第n個子元素。參數是元素的索引。索引從1開始。
n 可以是一個數字,一個關鍵字,或一個公式。
:nth-child 是CSS3 提供的一個好用的選擇器,因為在專案中常用到,所以簡單總結了它的常用方法,下面範例程式碼截圖用的是同一個例子,p元素的父元素都是body
p:nth-child(2)
表示為第2個p元素加上背景色, p:nth-child(3)是第3個p元素,依此類推
p:nth-child(2)
承接上面的範例,如果這裡的p元素前面還有其它元素,結果如下圖,段落1被添加背景色,而不是上面範例的段落2被添加背景色,
#因為這裡的p:nth-child(1)為h1元素,,所以p:nth-child(2)才為p元素
p:nth-child (3n)
表示給3的倍數的p元素加上背景色,2n就是2的倍數,4n就是4的倍數,以此類推
p:nth-child(odd)
表示為所有奇數p元素加入背景色
p:nth-child(even)
表示為所有偶數p元素添加背景色
使用公式(an b),描述:表示週期的長度,n 是計數器(從0 開始),b 是偏移值
註:公式裡的n,不區分大小寫
#p:nth-child(2n 1)
可以簡單理解為等同於p:nth-child(odd)
p:nth-child(2n 0)
以上是CSS裡面能用odd嗎的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Include:1)AsteeplearningCurvedUetoItsVasteCosystem,2)SeochallengesWithClient-SiderEndering,3)潛在的PersperformanceissuesInsuesInlArgeApplications,4)ComplexStateStateManagementAsappsgrow和5)TheneedtokeEedtokeEedtokeEppwithitsrapideDrapidevoltolution.thereedtokeEppectortorservolution.thereedthersrapidevolution.ththesefactorsshesssheou

reactischallengingforbeginnersduetoitssteplearningcurveandparadigmshifttocoment oparchitecent.1)startwithofficialdocumentationforasolidFoundation.2)了解jsxandhowtoembedjavascriptwithinit.3)

ThecorechallengeingeneratingstableanduniquekeysfordynamiclistsinReactisensuringconsistentidentifiersacrossre-rendersforefficientDOMupdates.1)Usenaturalkeyswhenpossible,astheyarereliableifuniqueandstable.2)Generatesynthetickeysbasedonmultipleattribute

javascriptfatigueinrectismanagbaiblewithstrategiesLike just just in-timelearninganning and CuratedInformationsources.1)學習whatyouneedwhenyouneedit

tateractComponents通過theusestatehook,使用jestandReaCtTestingLibraryToSigulationsimintionsandIntractions and verifyStateChangesInTheUI.1)underthecomponentAndComponentAndComponentAndConconentAndCheckInitialState.2)模擬useruseruserusertactionslikeclicksorformsorformsormissions.3)

KeysinreactarecrucialforopTimizingPerformanceByingIneFefitedListupDates.1)useKeyStoIndentifyAndTrackListelements.2)避免使用ArrayIndicesasKeystopreventperformansissues.3)ChooSestableIdentifierslikeIdentifierSlikeItem.idtomaintainAinainCommaintOnconMaintOmentStateAteanDimpperperFermerfermperfermerformperfermerformfermerformfermerformfermerment.ChosestopReventPerformissues.3)

ReactKeySareUniqueIdentifiers usedwhenrenderingListstoimprovereConciliation效率。 1)heelPreactrackChangesInListItems,2)使用StableanDuniqueIdentifiersLikeItifiersLikeItemidSisRecumended,3)避免使用ArrayIndicesaskeyindicesaskeystopreventopReventOpReventSissUseSuseSuseWithReRefers和4)

獨特的keysarecrucialinreactforoptimizingRendering和MaintainingComponentStateTegrity.1)useanaturalAlaluniqueIdentifierFromyourDataiFabable.2)ifnonaturalalientedifierexistsistsists,generateauniqueKeyniqueKeyKeyLiquekeyperaliqeyAliqueLiqueAlighatiSaliqueLiberaryLlikikeuuId.3)deversearrayIndiceSaskeyseSecialIndiceSeasseAsialIndiceAseAsialIndiceAsiall


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3漢化版
中文版,非常好用

Dreamweaver CS6
視覺化網頁開發工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

WebStorm Mac版
好用的JavaScript開發工具