TypechoJoeTheme

Dcr163的博客

统计

CSS3 结构性伪类选择器—last-child

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

“:last-child”选择器与“:first-child”选择器作用类似,不同的是“:last-child”选择器选择的是元素的最后一个子元素

例如:在CSS编辑器的第十四行输入正确的代码,删除列表中最后一个列表项的底部边框,为第一个li添加红色底框。

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<title>结构伪类选择器——last-child</title>
<style>
    ul {
      border: 1px solid #ccc;
      list-style: none outside none;
      width: 220px;
      margin: 20px auto;
      padding: 0;
    }
    ul > li {
      list-style: none outside none;
      margin:0;
      padding: 10px;
      border-bottom: 3px solid #ccc;
    }
    ul > li:first-child{
        border-bottom:3px solid red ;
    }
    ul > li:last-child {
      border-bottom: none;
    }
</style>
</head> 
<body>
<ul>
  <li>Item1</li>
  <li>Item2</li>
  <li>Item3</li>
  <li>Item5</li>
  <li>Item6</li>
</ul>
</body>
</html>


效果如:

朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

http://dcr163.cn/123.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

标签云