html - 通过 CSS 访问 html 内容?

标签 html css-selectors css

<div id=menu>
 <ul>
  <li class="section-title">auto-text1</li>
  <li class="section-title">auto-text2</li>
  <li class="section-title">auto-text3</li>
 </ul>
</div>

如何通过 css 对 auto-text3 进行特殊处理?

最佳答案

参见第 6.6.5.7 节。 CSS3 的 future 提案:

:last-child伪类

与 :nth-last-child(1) 相同。 :last-child 伪类表示一个元素是其他元素的最后一个子元素。

ul > li:last-child { }

http://www.w3.org/TR/css3-selectors/#last-child-pseudo

(在您的示例中 </menu> 可能意味着结束 </div> 。)

目前我想最好还是使用标记第一个和最后一个列表元素的类,或者在#menu id 上使用简单的 Javascript。

关于html - 通过 CSS 访问 html 内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2257387/

相关文章:

python - 无法使用 beautifulsoup 检索 <a> 标签 href(以 "?"而不是 http/s 开头)

html - 100% 宽度 textarea 在 IE7 中忽略父元素的宽度

php - jQuery 图像 slider 问题

html - 通配符选择器工作异常

html - Firefox 中的 flexbox

html - CSS/HTML : text on bar/table?

css - Next-sibling 组合器不应该与复杂的选择器一起使用

html - 包含带焦点输入的 div 的 CSS 选择器

html - flex 盒内部无法与带有伪元素的标签在末尾对齐

php - 样式化 wordpress 自定义类别模板