CSS显示不同颜色数字的排行榜

前端 作者:下载吧 2022-04-30 03:00:47

利用纯 CSS 设置 列表的 伪类 :after 实现不同颜色数字的排行榜效果。

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>纯CSS样式,显示不同颜色数字的排行榜列表</title>

<style>

ul{

   list-style: none;

}

li{

   position: relative;

   padding-left: 30px;

   height: 36px;

   line-height: 36px;

}

li:after{

   content: "";

   display: inline-block;

   width: 20px;

   height: 20px;

   line-height: 20px;

   text-align: center;

   color: #FFF;

   background: #999999;

   text-align: center;

   position: absolute;

   left: 0;

   top: 8px;

}

li:first-child:after {content: "1";background: #FD8C84;}

li:nth-child(2):after {content: "2";background: #FFCC99;}

li:nth-child(3):after {content: "3";background: #7FD75A;}

li:nth-child(4):after {content: "4";background: #CCCCFF;}

li:nth-child(5):after {content: "5";background: #60C4FD;}

li:nth-child(6):after {content: "6";}

li:nth-child(7):after {content: "7";}

li:nth-child(8):after {content: "8";}

</style>

</head>

<body>

<ul>

   <li>css设置背景图片位置固定</li>

   <li>暂停正在运行的css动画</li>

   <li>js最新手机号验证</li>

   <li>vue.js鼠标监听获取鼠标xy坐标</li>

   <li>vue.js获取时间代码</li>

   <li>js删除字符串最后一个字符或第一个字符</li>

   <li>js删除指定字符</li>

   <li>js替换指定字符串</li>

</ul>

</body>

</html>

HTML:

<ul>

   <li>css设置背景图片位置固定</li>

   <li>暂停正在运行的css动画</li>

   <li>js最新手机号验证</li>

   <li>vue.js鼠标监听获取鼠标xy坐标</li>

   <li>vue.js获取时间代码</li>

   <li>js删除字符串最后一个字符或第一个字符</li>

   <li>js删除指定字符</li>

   <li>js替换指定字符串</li>

</ul>

CSS

ul{

   list-style: none;

}

li{

   position: relative;

   padding-left: 30px;

   height: 36px;

   line-height: 36px;

}

li:after{

   content: "";

   display: inline-block;

   width: 20px;

   height: 20px;

   line-height: 20px;

   text-align: center;

   color: #FFF;

   background: #999999;

   text-align: center;

   position: absolute;

   left: 0;

   top: 8px;

}

li:first-child:after {content: "1";background: #FD8C84;}

li:nth-child(2):after {content: "2";background: #FFCC99;}

li:nth-child(3):after {content: "3";background: #7FD75A;}

li:nth-child(4):after {content: "4";background: #CCCCFF;}

li:nth-child(5):after {content: "5";background: C4FD;}

li:nth-child(6):after {content: "6";}

li:nth-child(7):after {content: "7";}

li:nth-child(8):after {content: "8";}


关注公众号:拾黑(shiheibook)了解更多

友情链接:

下软件就上简单下载站:https://www.jdsec.com/
四季很好,只要有你,文娱排行榜:https://www.yaopaiming.com/
让资讯触达的更精准有趣:https://www.0xu.cn/

公众号 关注网络尖刀微信公众号
随时掌握互联网精彩
赞助链接