【问题标题】:different css style for last each entrys最后每个条目的不同 css 样式
【发布时间】:2014-12-01 19:59:18
【问题描述】:

我有一个代码每隔一秒就会改变一个 each 的样式。

<?= $k % 2 == 1 ? 'news-figure' : 'news-figure-b' ?>

是否可以为最后的条目设置新样式?

【问题讨论】:

  • 你可以这样使用:li:last-child
  • 除了last-child,您还可以使用 CSS nth-of-type 消除执行 mod 2 的代码,例如可以使用 li:nth-of-type(2n+1) { background-color:red; } li:nth-of-type(2n) { background-color:green; } 完成交替颜色的列表项
  • 是的,这对我有用,谢谢,我使用了 nth-last-of-type

标签: php mysql css


【解决方案1】:

您可以使用伪元素:last-child 来应用css 样式。

在这里阅读更多:http://www.w3schools.com/cssref/sel_last-child.asp

【讨论】:

猜你喜欢
  • 2013-08-29
  • 1970-01-01
  • 2018-03-15
  • 2017-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-04
相关资源
最近更新 更多