TypechoJoeTheme

Dcr163的博客

统计

CSS3 only-child选择器

2017-03-09
/
0 评论
/
679 阅读
/
正在检测是否收录...
03/09

:only-child”选择器选择的是父元素中只有一个子元素,而且只有唯一的一个子元素。也就是说,匹配的元素的父元素中仅有一个子元素,而且是一个唯一的子元素

例如:通过“:only-child”选择器,改变只有一个列表项的背景色为橙色。

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style>
    li:only-child{
        background:orange;
    }
</style>
</head> 
<body>
<ul>
  <li>Item1</li>
  <li>Item2</li>
  <li>Item3</li>
</ul>
<ul>
  <li>Item1</li>
</ul>
<ol>
  <li>Item1</li>
</ol>
<ol>
  <li>Item1</li>
  <li>Item2</li>
  <li>Item3</li>
</ol>
</body>
</html>

朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

http://dcr163.cn/130.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. slot mpo terbaru
    2025-02-08
  2. Sherry Stockdill
    2025-01-28
  3. slot demo
    2025-01-13
  4. 陌天
    2025-01-09
  5. Kerrie Bostick
    2024-12-28

标签云