CSS修改默认列表元素样式(1.修改默认元素样式 2.伪元素选择器)

CSS自定义列表样式:圆、方块与自定义符号

CSS修改默认列表元素样式

1. 修改默认元素样式

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      @counter-style circled-alpha {
        system: fixed;
        symbols: Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ;
        suffix: " ";
      }

      ul > li {
        /* 默认实行圆 */
        /* list-style-type: disc;  */
        /* 空心圆 */
        /* list-style-type: circle;  */
        /* 实行方块 */
        /* list-style-type: square; */
        /* 阿拉伯数字有序列表 */
        /* list-style-type: decimal; */
        /* 格鲁吉亚符号 */
        /* list-style-type: georgian; */
        /* 汉字有序列表 */
        /* list-style-type: trad-chinese-informal; */
        /* 卡纳达符号 */
        /* list-style-type: kannada; */

        /* 自定义字符串符号(包括emoji) */
        /* list-style-type: '!~ '; */
        /* list-style-type: '⃞ '; */
        /* list-style-type: '⬜ '; */
        /* list-style-type: '◻️ '; */
        list-style-type: '🃉 ';

        /* @counter-style(可设置非常复杂的样式,要深入CSS的可以向下继续扩展https://drafts.csswg.org/css-counter-styles-3/#the-counter-style-rule) */
        /* list-style-type: circled-alpha; */
      }
    </style>
    <title>Document</title>
  </head>
  <body>
    <ul>
      <li>修改默认列表元素样式</li>
      <li>修改默认列表元素样式</li> 
      <li>修改默认列表元素样式</li>
    </ul>
  </body>
</html>

在这里插入图片描述

2. 或者使用伪元素选择器

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      ul > li {
          list-style: none;
      }

      /* 用伪元素选择器,可以自己在li标签前面加一个元素,想要大小和颜色都可以像设置div一样设置上去 */
      ul li::before{
          display: inline-block;
          content: '';
          width: 10px;
          height: 10px;
          margin: 0 10px 0 0;
          background-color: rgba(233, 235, 236,1);
      }
    </style>
    <title>Document</title>
  </head>
  <body>
    <ul>
      <li>修改默认列表元素样式</li>
      <li>修改默认列表元素样式</li> 
      <li>修改默认列表元素样式</li>
    </ul>
  </body>
</html>


在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值