×
CSS 参考手册CSS 选择器CSS 听觉参考手册CSS Web安全字体组合CSS 动画CSS 单位CSS 颜色CSS 合法颜色值CSS 颜色名称CSS 颜色十六进制值CSS 浏览器支持

CSS 属性

align-contentalign-itemsalign-selfallanimation(动画)animation-delayanimation-directionanimation-durationanimation-fill-modeanimation-iteration-countanimation-nameanimation-play-stateanimation-timing-functionappearancebackface-visibilitybackgroundbackground-attachmentbackground-blend-modebackground-clipbackground-colorbackground-imagebackground-originbackground-positionbackground-repeatbackground-sizeborderborder-bottomborder-bottom-colorborder-bottom-left-radiusborder-bottom-right-radiusborder-bottom-styleborder-bottom-widthborder-collapseborder-colorborder-imageborder-image-outsetborder-image-repeatborder-image-sliceborder-image-sourceborder-image-widthborder-leftborder-left-colorborder-left-styleborder-left-widthborder-radiusborder-rightborder-right-colorborder-right-styleborder-right-widthborder-spacingborder-styleborder-topborder-top-colorborder-top-left-radiusborder-top-right-radiusborder-top-styleborder-top-widthborder-widthbottombox-alignbox-directionbox-flexbox-flex-groupbox-linesbox-ordinal-groupbox-orientbox-packbox-shadowbox-sizingcaption-sideclearclipcolorcolumn-countcolumn-fillcolumn-gapcolumn-rulecolumn-rule-colorcolumn-rule-stylecolumn-rule-widthcolumn-spancolumn-widthcolumnscontentcounter-incrementcounter-resetcursordirectiondisplayempty-cellsfilter(滤镜)flexflex-basisflex-directionflex-flowflex-growflex-shrinkflex-wrapfloatfont@font-facefont-familyfont-sizefont-size-adjustfont-stretchfont-stylefont-variantfont-weightgrid-columnsgrid-rowshanging-punctuationheighticonjustify-content@keyframesleftletter-spacingline-heightlist-stylelist-style-imagelist-style-positionlist-style-typemarginmargin-bottommargin-leftmargin-rightmargin-topmax-heightmax-width@mediamin-heightmin-widthnav-downnav-indexnav-leftnav-rightnav-upopacityorderoutlineoutline-coloroutline-offsetoutline-styleoutline-widthoverflowoverflow-xoverflow-ypaddingpadding-bottompadding-leftpadding-rightpadding-toppage-break-afterpage-break-beforepage-break-insideperspectiveperspective-originpositionpunctuation-trimquotesresizerightrotationtab-sizetable-layouttargettarget-nametarget-newtarget-positiontext-aligntext-align-lasttext-decorationtext-decoration-colortext-decoration-linetext-decoration-styletext-indenttext-justifytext-outlinetext-overflowtext-shadowtext-transformtext-wraptoptransformtransform-origintransform-styletransitiontransition-delaytransition-durationtransition-propertytransition-timing-functionunicode-bidivertical-alignvisibilitywhite-spacewidthword-breakword-spacingword-wrapz-indexwriting-mode

CSS3 :nth-last-child() 选择器


CSS 选择器CSS 选择器


实例

指定每个p元素匹配同类型中的倒数第2个同级兄弟元素背景色:

p:nth-last-child(2)
{
background:#ff0000;
}

尝试一下 »

定义和用法

:nth-last-of-type(n)选择器匹配同类型中的倒数第n个同级兄弟元素。

n可以是一个数字,一个关键字,或者一个公式。

提示: 请参阅 :nth-last-of-type() 选择器。该选择器匹配父元素中的倒数第n个结构子元素。


浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

选择器
:nth-last-child() 4.0 9.0 3.5 3.2 9.6

Examples

更多实例


实例 1

奇数和偶数是可以作为关键字使用用于相匹配的子元素,其索引是奇数或偶数。

在这里,我们为奇数和偶数的倒数p元素指定两个不同的背景颜色:

p:nth-last-child(odd)
{
background:#ff0000;
}
p:nth-last-child(even)
{
background:#0000ff;
}

尝试一下 »

实例 2

使用公式(an+ b).描述:a代表一个循环的大小,N是一个计数器(从0开始),以及b是偏移量。

在这里,我们对所有索引是3的倍数的倒数顺序的p元素指定了背景颜色:

p:nth-last-child(3n+0)
{
background:#ff0000;
}

尝试一下 »

CSS 选择器CSS 选择器


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)