CSS3学习教程,从入门到精通, CSS3 列表控制详解语法知识点及案例代码(24)

news2025/4/1 20:18:16

CSS3 列表控制详解

CSS 列表控制的语法知识点及案例代码的详细说明,包括 list-style-type、list-style-image、list-style-position 和 list-style 的用法。

1. list-style-type 属性

list-style-type 属性用于设置列表项标记的类型。

语法

list-style-type: value;

常用值

  • none:无标记
  • disc:实心圆点(默认值)
  • circle:空心圆圈
  • square:实心方块
  • decimal:数字 1, 2, 3, 4…
  • decimal-leading-zero:数字 01, 02, 03, 04…
  • lower-roman:小写罗马数字 i, ii, iii, iv…
  • upper-roman:大写罗马数字 I, II, III, IV…
  • lower-alpha:小写字母 a, b, c, d…
  • upper-alpha:大写字母 A, B, C, D…
  • lower-greek:小写希腊字母 α, β, γ…
  • lower-latin:小写拉丁字母 (等同于 lower-alpha)
  • upper-latin:大写拉丁字母 (等同于 upper-alpha)
  • armenian:亚美尼亚数字
  • georgian:乔治亚数字

示例代码

<!DOCTYPE html>
<html>
<head>
<style>
  ul.custom {
    list-style-type: square; /* 使用方块作为列表标记 */
  }
  
  ol.decimal-leading-zero {
    list-style-type: decimal-leading-zero; /* 使用前导零的数字 */
  }
  
  ol.roman {
    list-style-type: lower-roman; /* 使用小写罗马数字 */
  }
</style>
</head>
<body>

<h2>自定义列表样式</h2>
<ul class="custom">
  <li>项目一</li>
  <li>项目二</li>
  <li>项目三</li>
</ul>

<ol class="decimal-leading-zero">
  <li>第一步</li>
  <li>第二步</li>
  <li>第三步</li>
</ol>

<ol class="roman">
  <li>第一章</li>
  <li>第二章</li>
  <li>第三章</li>
</ol>

</body>
</html>

2. list-style-image 属性

list-style-image 属性用于使用图像作为列表项标记。

语法

list-style-image: none|url|initial|inherit;

属性值

  • none:默认值,不使用图像
  • url:图像的路径
  • initial:设置为默认值
  • inherit:从父元素继承

示例代码

<!DOCTYPE html>
<html>
<head>
<style>
  ul.image-marker {
    list-style-image: url('https://via.placeholder.com/15x15'); /* 使用占位图片作为标记 */
  }
  
  ul.image-marker-fallback {
    /* 先尝试使用图片,如果图片不可用则使用方块 */
    list-style-type: square;
    list-style-image: url('nonexistent.png');
  }
</style>
</head>
<body>

<h2>图像作为列表标记</h2>
<ul class="image-marker">
  <li>带图片标记的项目一</li>
  <li>带图片标记的项目二</li>
  <li>带图片标记的项目三</li>
</ul>

<h2>带回退的图像标记</h2>
<ul class="image-marker-fallback">
  <li>如果图片不存在,会显示方块</li>
  <li>第二个项目</li>
</ul>

</body>
</html>

3. list-style-position 属性

list-style-position 属性用于设置列表项标记的位置。

语法

list-style-position: inside|outside|initial|inherit;

属性值

  • outside:默认值,标记位于列表项内容之外
  • inside:标记位于列表项内容之内
  • initial:设置为默认值
  • inherit:从父元素继承

示例代码

<!DOCTYPE html>
<html>
<head>
<style>
  ul.outside {
    list-style-position: outside; /* 默认值,标记在内容外 */
    border: 1px solid #ccc;
    width: 200px;
  }
  
  ul.inside {
    list-style-position: inside; /* 标记在内容内 */
    border: 1px solid #ccc;
    width: 200px;
  }
  
  li {
    background-color: #f8f8f8;
    margin: 5px 0;
  }
</style>
</head>
<body>

<h2>标记位置对比</h2>

<h3>outside (默认)</h3>
<ul class="outside">
  <li>列表项目一 - 标记在边框外</li>
  <li>列表项目二 - 文本对齐整齐</li>
</ul>

<h3>inside</h3>
<ul class="inside">
  <li>列表项目一 - 标记在边框内</li>
  <li>列表项目二 - 文本缩进与标记对齐</li>
</ul>

</body>
</html>

4. list-style 简写属性

list-style 属性是上述所有列表样式属性的简写形式。

语法

list-style: list-style-type list-style-position list-style-image;

使用说明

  • 可以按任意顺序指定值
  • 可以省略一个或多个值,未指定的值将使用默认值
  • 推荐顺序:type position image

示例代码

<!DOCTYPE html>
<html>
<head>
<style>
  ul.custom-shorthand {
    /* 使用简写属性设置列表样式 */
    list-style: square inside url('https://via.placeholder.com/15x15');
    width: 250px;
    border: 1px solid #ddd;
    padding: 10px;
  }
  
  ul.partial-shorthand {
    /* 只指定部分属性 */
    list-style: lower-alpha outside;
  }
  
  ul.reset {
    /* 重置列表样式 */
    list-style: none;
    padding-left: 0;
  }
</style>
</head>
<body>

<h2>list-style 简写属性</h2>

<ul class="custom-shorthand">
  <li>使用简写属性设置的列表项</li>
  <li>同时指定了类型、位置和图像</li>
  <li>图像优先显示,如果不可用则显示方块</li>
</ul>

<ul class="partial-shorthand">
  <li>只指定了类型和位置</li>
  <li>使用小写字母标记</li>
  <li>标记在内容外部</li>
</ul>

<h3>重置列表样式</h3>
<ul class="reset">
  <li>没有标记的列表</li>
  <li>常用于导航菜单</li>
</ul>

</body>
</html>

5. 高级应用案例

自定义计数器列表

<!DOCTYPE html>
<html>
<head>
<style>
  /* 自定义计数器样式 */
  ol.custom-counter {
    counter-reset: section; /* 初始化计数器 */
    list-style-type: none; /* 移除默认标记 */
    padding-left: 0;
  }
  
  ol.custom-counter li {
    counter-increment: section; /* 递增计数器 */
    margin-bottom: 10px;
    position: relative;
    padding-left: 30px;
  }
  
  ol.custom-counter li::before {
    /* 使用伪元素显示自定义计数器 */
    content: counter(section) ". "; /* 显示计数器值 */
    position: absolute;
    left: 0;
    width: 25px;
    height: 25px;
    background-color: #4CAF50;
    color: white;
    text-align: center;
    line-height: 25px;
    border-radius: 50%;
  }
  
  /* 多级嵌套计数器 */
  ol.nested-counter {
    counter-reset: chapter;
    list-style-type: none;
  }
  
  ol.nested-counter > li {
    counter-increment: chapter;
    counter-reset: section;
  }
  
  ol.nested-counter > li::before {
    content: counter(chapter) ". ";
    font-weight: bold;
  }
  
  ol.nested-counter ol {
    list-style-type: none;
    counter-reset: section;
    padding-left: 20px;
  }
  
  ol.nested-counter ol li {
    counter-increment: section;
  }
  
  ol.nested-counter ol li::before {
    content: counter(chapter) "." counter(section) " ";
  }
</style>
</head>
<body>

<h2>自定义计数器列表</h2>
<ol class="custom-counter">
  <li>第一个项目</li>
  <li>第二个项目</li>
  <li>第三个项目</li>
</ol>

<h2>嵌套计数器</h2>
<ol class="nested-counter">
  <li>第一章
    <ol>
      <li>第一节</li>
      <li>第二节</li>
    </ol>
  </li>
  <li>第二章
    <ol>
      <li>第一节</li>
      <li>第二节</li>
    </ol>
  </li>
</ol>

</body>
</html>

水平导航菜单

<!DOCTYPE html>
<html>
<head>
<style>
  /* 将列表转换为水平导航菜单 */
  ul.horizontal-nav {
    list-style-type: none; /* 移除标记 */
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
  }
  
  ul.horizontal-nav li {
    float: left; /* 使列表项水平排列 */
  }
  
  ul.horizontal-nav li a {
    display: block; /* 使整个区域可点击 */
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
  }
  
  ul.horizontal-nav li a:hover {
    background-color: #111;
  }
  
  /* 当前活动项 */
  ul.horizontal-nav li.active {
    background-color: #4CAF50;
  }
  
  /* 响应式设计 - 小屏幕时垂直堆叠 */
  @media screen and (max-width: 600px) {
    ul.horizontal-nav li {
      float: none;
    }
  }
</style>
</head>
<body>

<h2>水平导航菜单</h2>
<ul class="horizontal-nav">
  <li><a href="#home">首页</a></li>
  <li><a href="#news">新闻</a></li>
  <li class="active"><a href="#contact">联系</a></li>
  <li><a href="#about">关于</a></li>
</ul>

</body>
</html>

总结

CSS3 提供了强大的列表样式控制能力,主要包括:

  1. list-style-type - 控制列表标记的类型
  2. list-style-image - 使用自定义图像作为列表标记
  3. list-style-position - 控制标记的位置(内部或外部)
  4. list-style - 上述属性的简写形式

通过组合这些属性和其他CSS技术(如伪元素、计数器等),可以创建高度定制化的列表样式,满足各种设计需求。

CSS3 列表控制开发案例集

下面提供5个实际开发中常用的列表控制案例,每个案例都有详细注释和实际应用场景说明。

案例1:带图标的垂直导航菜单

<!DOCTYPE html>
<html>
<head>
<style>
  /* 垂直导航菜单样式 */
  .icon-nav {
    width: 200px;
    list-style: none; /* 移除默认列表样式 */
    padding: 0;
    margin: 0;
    font-family: Arial, sans-serif;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
    overflow: hidden; /* 隐藏溢出部分 */
  }
  
  .icon-nav li {
    border-bottom: 1px solid #e1e1e1;
  }
  
  .icon-nav li:last-child {
    border-bottom: none; /* 最后一个项目无下边框 */
  }
  
  .icon-nav a {
    display: flex; /* 使用flex布局对齐图标和文本 */
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease; /* 添加过渡效果 */
  }
  
  .icon-nav a:hover {
    background-color: #f5f5f5;
    color: #0066cc;
  }
  
  .icon-nav .icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    background-size: contain;
    background-repeat: no-repeat;
  }
  
  /* 为每个菜单项设置不同的图标 */
  .icon-home { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>'); }
  .icon-news { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"/></svg>'); }
  .icon-contact { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>'); }
  .icon-about { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg>'); }
  
  /* 悬停时改变图标颜色 */
  .icon-nav a:hover .icon {
    filter: invert(39%) sepia(90%) saturate(2000%) hue-rotate(190deg) brightness(90%) contrast(90%);
  }
</style>
</head>
<body>

<h3>带图标的垂直导航菜单</h3>
<ul class="icon-nav">
  <li><a href="#"><span class="icon icon-home"></span>首页</a></li>
  <li><a href="#"><span class="icon icon-news"></span>新闻中心</a></li>
  <li><a href="#"><span class="icon icon-contact"></span>联系我们</a></li>
  <li><a href="#"><span class="icon icon-about"></span>关于我们</a></li>
</ul>

</body>
</html>

应用场景:后台管理系统侧边栏、网站主导航

案例2:步骤指示器

<!DOCTYPE html>
<html>
<head>
<style>
  /* 步骤指示器样式 */
  .step-indicator {
    list-style: none;
    padding: 0;
    margin: 30px 0;
    display: flex;
    justify-content: space-between;
    counter-reset: step-counter; /* 初始化计数器 */
  }
  
  .step-indicator li {
    flex: 1;
    position: relative;
    text-align: center;
    font-size: 14px;
    color: #999;
  }
  
  /* 步骤编号 */
  .step-indicator li::before {
    counter-increment: step-counter; /* 递增计数器 */
    content: counter(step-counter); /* 显示计数器值 */
    display: block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background-color: #e0e0e0;
    color: #999;
    font-weight: bold;
  }
  
  /* 连接线 */
  .step-indicator li::after {
    content: '';
    position: absolute;
    top: 15px;
    left: -50%;
    width: 100%;
    height: 2px;
    background-color: #e0e0e0;
    z-index: -1;
  }
  
  /* 第一个项目不需要连接线 */
  .step-indicator li:first-child::after {
    display: none;
  }
  
  /* 当前步骤样式 */
  .step-indicator li.active {
    color: #4285f4;
  }
  
  .step-indicator li.active::before {
    background-color: #4285f4;
    color: white;
  }
  
  /* 已完成步骤样式 */
  .step-indicator li.completed {
    color: #34a853;
  }
  
  .step-indicator li.completed::before {
    background-color: #34a853;
    color: white;
    content: '✓'; /* 使用对勾代替数字 */
  }
  
  .step-indicator li.completed::after {
    background-color: #34a853;
  }
</style>
</head>
<body>

<h3>订单流程步骤指示器</h3>
<ul class="step-indicator">
  <li class="completed">选择商品</li>
  <li class="completed">填写信息</li>
  <li class="active">支付订单</li>
  <li>等待发货</li>
  <li>完成评价</li>
</ul>

</body>
</html>

应用场景:电商订单流程、多步骤表单、注册流程

案例3:新闻资讯列表

<!DOCTYPE html>
<html>
<head>
<style>
  /* 新闻列表样式 */
  .news-list {
    list-style: none;
    padding: 0;
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Helvetica Neue', Arial, sans-serif;
  }
  
  .news-item {
    display: flex;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
  }
  
  .news-item:last-child {
    border-bottom: none;
  }
  
  .news-date {
    flex: 0 0 100px;
    text-align: center;
    margin-right: 20px;
  }
  
  .news-day {
    font-size: 28px;
    font-weight: bold;
    color: #4285f4;
    display: block;
    line-height: 1;
  }
  
  .news-month {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    display: block;
  }
  
  .news-content {
    flex: 1;
  }
  
  .news-title {
    font-size: 18px;
    margin: 0 0 8px 0;
    color: #333;
  }
  
  .news-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
  }
  
  .news-title a:hover {
    color: #4285f4;
  }
  
  .news-summary {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 10px 0;
  }
  
  .news-meta {
    font-size: 12px;
    color: #999;
  }
  
  .news-meta span {
    margin-right: 15px;
  }
  
  .news-meta .category {
    color: #34a853;
    font-weight: bold;
  }
  
  /* 响应式设计 */
  @media (max-width: 600px) {
    .news-item {
      flex-direction: column;
    }
    
    .news-date {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
    }
    
    .news-day {
      margin-right: 10px;
      font-size: 24px;
    }
    
    .news-month {
      font-size: 12px;
    }
  }
</style>
</head>
<body>

<h3>新闻资讯列表</h3>
<ul class="news-list">
  <li class="news-item">
    <div class="news-date">
      <span class="news-day">15</span>
      <span class="news-month">Jun</span>
    </div>
    <div class="news-content">
      <h4 class="news-title"><a href="#">公司发布新一代人工智能产品</a></h4>
      <p class="news-summary">我们很高兴地宣布推出全新AI解决方案,该产品将彻底改变企业工作流程...</p>
      <div class="news-meta">
        <span class="category">公司动态</span>
        <span>作者: 张经理</span>
        <span>阅读: 1245</span>
      </div>
    </div>
  </li>
  <li class="news-item">
    <div class="news-date">
      <span class="news-day">08</span>
      <span class="news-month">Jun</span>
    </div>
    <div class="news-content">
      <h4 class="news-title"><a href="#">2023年技术峰会在上海成功举办</a></h4>
      <p class="news-summary">为期三天的技术峰会吸引了来自全球的2000多名开发者参与,共同探讨前沿技术发展趋势...</p>
      <div class="news-meta">
        <span class="category">行业资讯</span>
        <span>作者: 李编辑</span>
        <span>阅读: 892</span>
      </div>
    </div>
  </li>
  <li class="news-item">
    <div class="news-date">
      <span class="news-day">01</span>
      <span class="news-month">Jun</span>
    </div>
    <div class="news-content">
      <h4 class="news-title"><a href="#">夏季促销活动即将开始</a></h4>
      <p class="news-summary">为庆祝公司成立10周年,我们将在6月10日至20日期间推出全场商品8折优惠...</p>
      <div class="news-meta">
        <span class="category">促销活动</span>
        <span>作者: 王主管</span>
        <span>阅读: 1567</span>
      </div>
    </div>
  </li>
</ul>

</body>
</html>

应用场景:企业新闻页面、博客文章列表、资讯中心

案例4:产品功能列表

<!DOCTYPE html>
<html>
<head>
<style>
  /* 产品功能列表样式 */
  .feature-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
  }
  
  .feature-item {
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
  }
  
  .feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  }
  
  .feature-icon {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4285f4, #34a853);
  }
  
  .feature-icon svg {
    width: 40px;
    height: 40px;
    fill: white;
  }
  
  .feature-content {
    padding: 25px;
  }
  
  .feature-title {
    font-size: 18px;
    margin: 0 0 15px 0;
    color: #333;
  }
  
  .feature-desc {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    margin: 0;
  }
  
  /* 不同功能项使用不同颜色 */
  .feature-item:nth-child(2) .feature-icon {
    background: linear-gradient(135deg, #ea4335, #fbbc05);
  }
  
  .feature-item:nth-child(3) .feature-icon {
    background: linear-gradient(135deg, #34a853, #4285f4);
  }
  
  .feature-item:nth-child(4) .feature-icon {
    background: linear-gradient(135deg, #fbbc05, #ea4335);
  }
  
  /* 响应式设计 */
  @media (max-width: 768px) {
    .feature-list {
      grid-template-columns: 1fr;
    }
  }
</style>
</head>
<body>

<h3>产品核心功能</h3>
<ul class="feature-list">
  <li class="feature-item">
    <div class="feature-icon">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
        <path d="M3.27 6.96L12 12.01l8.73-5.05M12 22.08V12"></path>
      </svg>
    </div>
    <div class="feature-content">
      <h4 class="feature-title">安全可靠</h4>
      <p class="feature-desc">采用银行级加密技术,确保您的数据安全无忧。多重备份机制,99.99%的服务可用性保证。</p>
    </div>
  </li>
  <li class="feature-item">
    <div class="feature-icon">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <path d="M22 12h-4l-3 9L9 3l-3 9H2"></path>
      </svg>
    </div>
    <div class="feature-content">
      <h4 class="feature-title">极速性能</h4>
      <p class="feature-desc">全球CDN加速,毫秒级响应。优化的算法架构,比传统方案快3倍以上。</p>
    </div>
  </li>
  <li class="feature-item">
    <div class="feature-icon">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
        <circle cx="9" cy="7" r="4"></circle>
        <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
        <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
      </svg>
    </div>
    <div class="feature-content">
      <h4 class="feature-title">团队协作</h4>
      <p class="feature-desc">实时多人协作编辑,权限精细控制。历史版本追溯,随时恢复任意版本。</p>
    </div>
  </li>
  <li class="feature-item">
    <div class="feature-icon">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"></path>
      </svg>
    </div>
    <div class="feature-content">
      <h4 class="feature-title">智能分析</h4>
      <p class="feature-desc">内置AI分析引擎,自动生成可视化报表。预测趋势,辅助决策。</p>
    </div>
  </li>
</ul>

</body>
</html>

应用场景:产品介绍页面、服务特色展示、解决方案功能点

案例5:带复选框的任务列表

<!DOCTYPE html>
<html>
<head>
<style>
  /* 任务列表样式 */
  .task-list {
    list-style: none;
    padding: 0;
    max-width: 600px;
    margin: 30px auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  }
  
  .task-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
  }
  
  .task-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
  }
  
  /* 自定义复选框样式 */
  .task-checkbox {
    position: relative;
    margin-right: 15px;
  }
  
  .task-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
  }
  
  .checkmark {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s;
  }
  
  .task-checkbox input:checked ~ .checkmark {
    background-color: #34a853;
    border-color: #34a853;
  }
  
  /* 对勾图标 */
  .checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  
  .task-checkbox input:checked ~ .checkmark:after {
    display: block;
  }
  
  .task-content {
    flex: 1;
  }
  
  .task-title {
    font-weight: 500;
    margin: 0 0 3px 0;
    color: #333;
  }
  
  .task-desc {
    font-size: 13px;
    color: #777;
    margin: 0;
  }
  
  /* 已完成任务样式 */
  .task-item.completed .task-title {
    color: #999;
    text-decoration: line-through;
  }
  
  .task-item.completed .task-desc {
    color: #bbb;
  }
  
  /* 优先级标签 */
  .task-priority {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 10px;
    margin-left: 15px;
    font-weight: bold;
  }
  
  .priority-high {
    background-color: #fce8e6;
    color: #d93025;
  }
  
  .priority-medium {
    background-color: #fef7e0;
    color: #f9ab00;
  }
  
  .priority-low {
    background-color: #e6f4ea;
    color: #34a853;
  }
  
  /* 截止日期 */
  .task-due {
    font-size: 12px;
    color: #777;
    margin-left: 15px;
    white-space: nowrap;
  }
  
  .task-due.overdue {
    color: #d93025;
    font-weight: bold;
  }
</style>
</head>
<body>

<h3>任务管理列表</h3>
<ul class="task-list">
  <li class="task-item">
    <label class="task-checkbox">
      <input type="checkbox" checked>
      <span class="checkmark"></span>
    </label>
    <div class="task-content">
      <h4 class="task-title">完成项目需求文档</h4>
      <p class="task-desc">整理客户需求并编写详细的功能规格说明书</p>
    </div>
    <span class="task-priority priority-high">高优先级</span>
    <span class="task-due">今天</span>
  </li>
  <li class="task-item completed">
    <label class="task-checkbox">
      <input type="checkbox" checked>
      <span class="checkmark"></span>
    </label>
    <div class="task-content">
      <h4 class="task-title">团队周例会</h4>
      <p class="task-desc">讨论项目进度和下周工作计划</p>
    </div>
    <span class="task-priority priority-medium">中优先级</span>
    <span class="task-due">周一</span>
  </li>
  <li class="task-item">
    <label class="task-checkbox">
      <input type="checkbox">
      <span class="checkmark"></span>
    </label>
    <div class="task-content">
      <h4 class="task-title">UI设计评审</h4>
      <p class="task-desc">与设计团队讨论新版界面设计方案</p>
    </div>
    <span class="task-priority priority-medium">中优先级</span>
    <span class="task-due">周三</span>
  </li>
  <li class="task-item">
    <label class="task-checkbox">
      <input type="checkbox">
      <span class="checkmark"></span>
    </label>
    <div class="task-content">
      <h4 class="task-title">学习新技术</h4>
      <p class="task-desc">完成React新特性学习并写demo</p>
    </div>
    <span class="task-priority priority-low">低优先级</span>
    <span class="task-due overdue">上周五</span>
  </li>
</ul>

</body>
</html>

应用场景:任务管理系统、待办事项应用、项目管理工具

这些案例涵盖了从简单到复杂的各种列表应用场景,展示了CSS3列表控制的强大功能和灵活性。您可以根据实际需求进行调整和扩展。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2325015.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

NSSCTF(MISC)—[justCTF 2020]pdf

相应的做题地址&#xff1a;https://www.nssctf.cn/problem/920 binwalk分离 解压文件2AE59A.zip mutool 得到一张图片 B5F31内容 B5FFD内容 转换成图片 justCTF{BytesAreNotRealWakeUpSheeple}

坚持“大客户战略”,昂瑞微深耕全球射频市场

北京昂瑞微电子技术股份有限公司&#xff08;简称“昂瑞微”&#xff09;是一家聚焦射频与模拟芯片设计的高新技术企业。随着5G时代的全面到来&#xff0c;智能手机、智能汽车等终端设备对射频前端器件在通信频率、多频段支持、信道带宽及载波聚合等方面提出了更高需求&#xf…

LiteDB 数据库优缺点分析与C#代码示例

LiteDB 是一个轻量级的 .NET NoSQL 嵌入式数据库,完全用 C# 开发,支持跨平台(Windows、Linux、MacOS),并提供类似于 MongoDB 的简单 API。它以单文件形式存储数据,类似于 SQLite,支持事务和 ACID 特性,确保数据的一致性和可靠性。 优缺点分析 优点: 轻量级与嵌入式:…

Linux系统中快速安装docker

1 查看是否安装docker 要检查Ubuntu是否安装了Docker&#xff0c;可以使用以下几种方法&#xff1a; 方法1&#xff1a;使用 docker --version 命令 docker --version如果Docker已安装&#xff0c;输出会显示Docker的版本信息&#xff0c;例如&#xff1a; Docker version …

CP15 协处理器

ARMv7-A 一共支持 16 个协处理器&#xff0c;编号从 CP0~CP15。这里仅对CP15进行描述。 1、ARMv7-A 协处理器 ARMv7-A 处理器除了标准的 R0~R15&#xff0c;CPSR&#xff0c;SPSR 以外&#xff0c;由于引入了 MMU、TLB、Cache 等内容&#xff0c;ARMv7-A 使用协处理器来对这些…

网络运维学习笔记(DeepSeek优化版)026 OSPF vlink(Virtual Link,虚链路)配置详解

文章目录 OSPF vlink&#xff08;Virtual Link&#xff0c;虚链路)配置详解1. 虚链路核心特性2. 基础配置命令3. 状态验证命令3.1 查看虚链路状态3.2 验证LSDB更新 4. 关键技术要点4.1 路径选择机制4.2 虚链路的链路优化 5. 环路风险案例 OSPF vlink&#xff08;Virtual Link&a…

【区块链安全 | 第十六篇】类型之值类型(三)

文章目录 函数类型声明语法转换成员合约更新时的值稳定性示例 函数类型 函数类型是函数的类型。函数类型的变量可以通过函数进行赋值&#xff0c;函数类型的参数可以用来传递函数并返回函数。 函数类型有两种类型&#xff1a;内部函数和外部函数。 内部函数只能在当前合约内调…

Kubernetes对象基础操作

基础操作 文章目录 基础操作一、创建Kubernetes对象1.使用指令式命令创建Deployment2.使用指令式对象配置创建Deployment3.使用声明式对象配置创建Deployment 二、操作对象的标签1.为对象添加标签2.修改对象的标签3.删除对象标签4.操作具有指定标签的对象 三、操作名称空间四、…

Java与代码审计-Java基础语法

Java基础语法 package com.woniuxy.basic;public class HelloWorld {//入口函数public static void main(String[] args){System.out.println("Hello World");for(int i0;i< args.length;i){System.out.println(args[i]);}} }运行结果如下: 但是下面那个没有参数…

Xenium | 细胞邻域(Cellular Neighborhood)分析(fixed radius)

上节我们介绍了空间转录组数据分析中常见的细胞邻域分析&#xff0c;CN计算过程中定义是否为细胞邻居的方法有两种&#xff0c;一种是上节我们使用固定K最近邻方法(fixed k-nearest neighbors)定义细胞Neighborhood&#xff0c;今天我们介绍另外一种固定半径范围内(fixed radiu…

Python:爬虫概念与分类

网络请求&#xff1a; https://www.baidu.com url——统一资源定位符 请求过程&#xff1a; 客户端&#xff0c;指web浏览器向服务器发送请求 请求&#xff1a;请求网址(request url)&#xff1b;请求方法(request methods)&#xff1b;请求头(request header)&…

SQLMesh调度系统深度解析:内置调度与Airflow集成实践

本文系统解析SQLMesh的两种核心调度方案&#xff1a;内置调度器与Apache Airflow集成。通过对比两者的适用场景、架构设计和操作流程&#xff0c;为企业构建可靠的数据分析流水线提供技术参考。重点内容包括&#xff1a; 内置调度器的轻量级部署与性能优化策略Airflow集成的端到…

Multism TL494仿真异常

仿真模型如下&#xff1a;开关频率少了一半&#xff0c;而且带不动负载&#xff0c;有兄弟知道为什么吗 这里写自定义目录标题 欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题&#xff0c;有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码…

HarmonyOS NEXT开发进阶(十五):日志打印 hilog 与 console.log 的区别

文章目录 一、前言二、两者区别对比三、HiLog 详解四、拓展阅读 一、前言 在日常开发阶段&#xff0c;日志打印是调试程序非常常用的操作&#xff0c;在鸿蒙的官方文档中介绍了hilog这种方式&#xff0c;前端转过来的开发者发现console.log也可以进行日志打印&#xff0c;而且…

vue 权限应用

目录 一、系统菜单栏权限 二、系统页面按钮权限 在企业开发中&#xff0c;不同的用户所扮演的角色不一样&#xff0c;角色拥有权限&#xff0c;所以用户拥有角色&#xff0c;就会有角色对应的权限。例如&#xff0c;张三是系统管理员角色&#xff0c;登录后就拥有整个系统的…

鸿蒙HarmonyOS NEXT设备升级应用数据迁移流程

数据迁移是什么 什么是数据迁移&#xff0c;对用户来讲就是本地数据的迁移&#xff0c;终端设备从HarmonyOS 3.1 Release API 9及之前版本&#xff08;单框架&#xff09;迁移到HarmonyOS NEXT&#xff08;双框架&#xff09;后保证本地数据不丢失。例如&#xff0c;我在某APP…

利用 PCI-Express 交换机实现面向未来的推理服务器

在数据中心系统的历史上&#xff0c;没有比被 Nvidia 选为其 AI 系统的组件供应商更高的赞誉了。 这就是为什么新兴的互连芯片制造商 Astera Labs 感到十分高兴&#xff0c;因为该公司正在 PCI-Express 交换机、PCI-Express 重定时器和 CXL 内存控制器方面与 Broadcom 和 Marv…

Python if else while for 学习笔记

一.if&#xff0c;else if语句用于根据条件执行代码块 else语句可与if语句结合&#xff0c;当if判断为假时执行else语句 x10 if x>5:print("x大于5") y3 if y>5:print("y大于5") else:print("y小于等于5")结果&#xff1a; 二.while循环…

正则化是什么?

正则化&#xff08;Regularization&#xff09;是机器学习中用于防止模型过拟合&#xff08;Overfitting&#xff09;的一种技术&#xff0c;通过在模型训练过程中引入额外的约束或惩罚项&#xff0c;降低模型的复杂度&#xff0c;从而提高其泛化能力&#xff08;即在未见数据上…

搜索-BFS

马上蓝桥杯了&#xff0c;最近刷了广搜&#xff0c;感觉挺有意思的&#xff0c;广搜题类型都差不多&#xff0c;模板也一样&#xff0c;大家写的时候可以直接套模板 这里给大家讲一个比较经典的广搜题-迷宫 题目问问能否走到 (n,m) 位置&#xff0c;假设最后一个点是我们的&…