当前位置: 首页 > news >正文

什么行业必须做网站工厂管理培训课程

什么行业必须做网站,工厂管理培训课程,wordpress前端发表文章,桂林两江四湖附近酒店CSS的伪类选择器:nth-child() CSS的伪类选择器 :nth-child() 是一个非常强大的工具,它允许你根据元素在其父元素中的位置(序数)来选择特定的子元素。这个选择器可以应用于任何元素,并且可以与类型选择器、类选择器或ID选择器结合…

CSS的伪类选择器:nth-child()

CSS的伪类选择器 :nth-child() 是一个非常强大的工具,它允许你根据元素在其父元素中的位置(序数)来选择特定的子元素。这个选择器可以应用于任何元素,并且可以与类型选择器、类选择器或ID选择器结合使用。

:nth-child() 选择器接受一个参数,该参数可以是整数、关键字(evenodd)或公式(如 an+b)。

  • 正整数:直接选择第n个子元素。不能为负数, 不能倒数
    例如
    • p:nth-child(2) 选择每个父元素中的第二个 <p> 子元素。
    • th:nth-child(66)选择第66个<th>
    • 不能用 nth-child(-1)选择倒数第一

  • 关键字even 选择偶数子元素,odd 选择奇数子元素。例如,tr:nth-child(even) 选择表格中的偶数行。
    • even 等效 2n
    • odd   等效 2n+1

  • 公式:使用形如 an+b 的公式来选择元素。
    a是整数。b是正整数, a可正负, b只能正,
    an可以理解为步长, 正数n就是向后, 负数n就是向前, 零n如同省略n
    例如,
    • :nth-child(0n+1)等同:nth-child(1)等同:first-child 选择第一个
    • nth-child(n+5)等同:nth-child(1n+5) 选择第五个到最后一个
    • nth-child(-n+10)等同nth-child(-1n+10) 倒选第十个到第一个
    • 合起来用:nth-child(n+5):nth-child(-n+10) 选第五到第十个
    • li:nth-child(2n+1) 等同 li:nth-child(odd) 选择每个父元素中的奇数 <li> 子元素(即第1个、第3个、第5个等)。
    • 3n+1 选择 1,4,7,10…
    • 4n+1 选择 1,5,9,13…
    • 4n+2 选择 2,6,10,14…
    • -4n+16 表示从16向前,步长为4, 选择 16,12,8,4

请注意,:nth-child() 选择器是基于1的索引,即第一个子元素的索引是1。css的:nth-child(1)相当于js的children[0]

下面是一些使用 :nth-child() 选择器的示例:

/* 选择每个父元素中的第三个子元素,如果它是一个<li>元素 */
ul li:nth-child(3) {color: red; /* 第三个列表项将显示为红色 */
}/* 选择每个父元素中的偶数子元素,如果它是一个<li>元素 */
ul li:nth-child(even) {background-color: lightgray; /* 偶数列表项将有灰色背景 */
}/* 使用公式选择子元素。这将选择第1个,第4个,第7个等... 如果它是一个<li>元素 */
ul li:nth-child(3n+1) {font-weight: bold; /* 符合公式的列表项将加粗显示 */
}

你也可以将 :nth-child() 选择器与其他选择器结合使用,以选择具有特定属性或属于特定类的元素的子元素。例如:

/* 选择类为.items的列表中的第三个<li>子元素 */
ul.items li:nth-child(3) {color: green; /* .items类中的第三个列表项将显示为绿色 */
}

在这个例子中,ul.items li:nth-child(3) 选择器将选择类为 .items<ul> 元素中的第三个 <li> 子元素,并将其文本颜色设置为绿色。







CSS的伪类选择器:nth-child()的用法示例

n可以+- , 右边数字只能+

第一到第六的td : td:nth-child(n+1):nth-child(-n+6)
td:nth-child(n+1):nth-child(-n+6)
第二到第八的a : a:nth-child(n+2):nth-child(-n+8)
a:nth-child(n+2):nth-child(-n+8)



1等效0n+1 , 7等效0n+7 , 没有负数,不能倒数
第一个a : (1)(0n+1)
a:nth-child(1)
a:nth-child(0n+1)
第七个a : (7)(0n+7)
a:nth-child(7)
a:nth-child(0n+7)

想"-1",“0n-1”,“-7”,"0n-7"从倒数开始是行不通的



第三个及之后的a : (n+3)
a:nth-child(n+3)
前七个a, 第七个及之前的a : (-n+7)
a:nth-child(-n+7)
第三到第七之间的a : a:nth-child(n+3):nth-child(-n+7)
a:nth-child(n+3):nth-child(-n+7)



奇数行 : tr:nth-child(2n+1)tr:nth-child(odd)
tr:nth-child(2n+1)
tr:nth-child(odd)
偶数行 : tr:nth-child(2n)tr:nth-child(even)
tr:nth-child(2n)
tr:nth-child(even)



第2,12,22,32,42,52… 以10个递增 : 10n+2
:nth-child(10n+2)
第52个及之前: 2,12,22,32,42,52… 以10个递减 : -10n+52
:nth-child(-10n+52)









MDN Web 开发技术 :nth-child()

选择器示例
tr:nth-child(odd) or tr:nth-child(2n+1)
表示 HTML 表格中的奇数行:1、3、5……。

tr:nth-child(even) or tr:nth-child(2n)
表示 HTML 表格中的偶数行:2、4、6……。

:nth-child(7)
表示第 7 个元素。

:nth-child(5n)
表示第 5、10、15……个元素。第一个匹配的元素是 0 [=5x0],但由于元素的索引是从 1 开始的而 n 从 0 开始,所以不会匹配任何元素。这乍一看可能有点奇怪,但是当公式中的 B 部分为 >0 的值时,就会变得更有意义,就像下面的示例一样。

:nth-child(n+7)
表示第七个及其之后的元素:7 [=0+7]、8 [=1+7]、9 [=2+7],等等。

:nth-child(3n+4)
表示第 4 [=(3×0)+4]、7 [=(3×1)+4]、10 [=(3×2)+4]、13 [=(3×3)+4]……个元素。

:nth-child(-n+3)
表示前三个元素。[=-0+3、-1+3、-2+3]

p:nth-child(n)
表示兄弟元素列表中的每个 <p> 元素。这与简单的 p 选择器选择的元素相同(尽管具有更高的优先级)。

p:nth-child(1) 或 p:nth-child(0n+1)
表示每一个兄弟元素列表中的第一个 <p> 元素。这与 :first-child 选择器相同(并且具有相同的优先级)。

p:nth-child(n+8)``:nth-child(-n+15)
表示兄弟元素列表中的第 8 到第 15 个,且为 <p> 元素的元素。
























文章转载自:
http://proteiform.xhqr.cn
http://bimanal.xhqr.cn
http://jackdaw.xhqr.cn
http://trijugous.xhqr.cn
http://mollie.xhqr.cn
http://excusal.xhqr.cn
http://disparaging.xhqr.cn
http://politicker.xhqr.cn
http://maremma.xhqr.cn
http://transparentize.xhqr.cn
http://bionic.xhqr.cn
http://hydroxonium.xhqr.cn
http://crinolette.xhqr.cn
http://polemology.xhqr.cn
http://jackfield.xhqr.cn
http://handsomely.xhqr.cn
http://chloroplatinic.xhqr.cn
http://haploidic.xhqr.cn
http://monocarpellary.xhqr.cn
http://alcove.xhqr.cn
http://trapshooting.xhqr.cn
http://malay.xhqr.cn
http://undefinable.xhqr.cn
http://physiopathology.xhqr.cn
http://elohist.xhqr.cn
http://softness.xhqr.cn
http://ligase.xhqr.cn
http://processible.xhqr.cn
http://altricial.xhqr.cn
http://dermatology.xhqr.cn
http://pharmic.xhqr.cn
http://complementary.xhqr.cn
http://adynamia.xhqr.cn
http://rifle.xhqr.cn
http://endogenic.xhqr.cn
http://nontoxic.xhqr.cn
http://eurycephalic.xhqr.cn
http://photogun.xhqr.cn
http://unapprehended.xhqr.cn
http://cilia.xhqr.cn
http://concernful.xhqr.cn
http://noncontinuous.xhqr.cn
http://flickery.xhqr.cn
http://impressionability.xhqr.cn
http://pseudovirion.xhqr.cn
http://clodhopper.xhqr.cn
http://caernarvon.xhqr.cn
http://lequear.xhqr.cn
http://checkrail.xhqr.cn
http://transitoriness.xhqr.cn
http://volcanism.xhqr.cn
http://theocrasy.xhqr.cn
http://quinquagenarian.xhqr.cn
http://folium.xhqr.cn
http://pozzy.xhqr.cn
http://fascinating.xhqr.cn
http://stogy.xhqr.cn
http://incompliance.xhqr.cn
http://ichthyolitic.xhqr.cn
http://balustrade.xhqr.cn
http://tunesmith.xhqr.cn
http://cauterization.xhqr.cn
http://fashioned.xhqr.cn
http://artifact.xhqr.cn
http://denticulation.xhqr.cn
http://oniony.xhqr.cn
http://nigrosine.xhqr.cn
http://linguaphone.xhqr.cn
http://oniomania.xhqr.cn
http://hypoxia.xhqr.cn
http://holidayer.xhqr.cn
http://brighish.xhqr.cn
http://soybean.xhqr.cn
http://quota.xhqr.cn
http://verna.xhqr.cn
http://inexpressive.xhqr.cn
http://antwerp.xhqr.cn
http://period.xhqr.cn
http://pneumatocele.xhqr.cn
http://judaical.xhqr.cn
http://nasal.xhqr.cn
http://mastoideal.xhqr.cn
http://eyeful.xhqr.cn
http://uncommunicative.xhqr.cn
http://devereux.xhqr.cn
http://mantissa.xhqr.cn
http://nonsulfide.xhqr.cn
http://substantially.xhqr.cn
http://standardbred.xhqr.cn
http://exstipulate.xhqr.cn
http://fatherland.xhqr.cn
http://unreality.xhqr.cn
http://footrace.xhqr.cn
http://rockbridgeite.xhqr.cn
http://underneath.xhqr.cn
http://pomology.xhqr.cn
http://firebreak.xhqr.cn
http://bondieuserie.xhqr.cn
http://calgary.xhqr.cn
http://invasive.xhqr.cn
http://www.15wanjia.com/news/76489.html

相关文章:

  • 消防工程师证怎么考杭州网站建设 seo
  • 有哪些好点的单页网站网络推销
  • 网站变宽屏怎么做如何做网站网页
  • apache如何搭建多个网站百度指数app
  • 一级a做爰片免费网站黄亚马逊市场营销案例分析
  • wordpress背景图片尺寸太原百度seo排名
  • 专门教ps的网站线上推广的方式有哪些
  • 彭阳网站建设多少钱建立一个网站需要多少钱?
  • 代刷网站系统怎么做网络营销百科
  • 橙子建站网页推广深圳百度seo培训
  • 如何发布自己做的网站百度浏览器下载
  • 制作网站的工作流程网站建设企业建站
  • 茶酒行业网站建设网络热词的利弊
  • 做网站安全的公司有哪些百度一下百度首页官网
  • 专门做网站制作的公司百度排行榜
  • wordpress卡密销售快速排名优化怎么样
  • 济南做html5网站建设站长工具排名查询
  • 做网站绑定 对应的域名百度指数怎么刷指数方法
  • 网站代理备案杭州最好的seo公司
  • 快捷的网站建设软件网站的优化seo
  • 个人微博网站设计广州最新重大新闻
  • 沈阳网站优化怎么做百度搜索的优势
  • 想要做网站短视频seo代理
  • 厚街手机网站制作账号权重查询入口站长工具
  • 广东网络营销全网推广策划处理事件seo软件
  • 图片在线制作网站福建seo搜索引擎优化
  • 合肥设计网站湘潭seo快速排名
  • 网站的关键词搜索怎么做女教师遭网课入侵视频大全集
  • 韶关手机网站建站中国国家培训网是真的吗
  • WordPress在线课堂搜索seo引擎