前端ul好看的li列表样式

饭宝  金牌会员 | 2024-6-14 22:29:46 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 576|帖子 576|积分 1728

效果

以下是实际效果截图:

html文件

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <style>
  5.         .other-item-title {
  6.             margin: 10px 20px;
  7.             padding: 5px;
  8.             line-height: 30px;
  9.             font-weight: 400;
  10.             border-bottom: 1px solid #e8e9e7;
  11.             color: #383937;
  12.             position: relative;
  13.             font-size: 18px
  14.         }
  15.         .other-item .inner {
  16.             margin: 0 20px;
  17.             padding-bottom: 10px
  18.         }
  19.         .inner .hot-list-article li {
  20.             display: block;
  21.             line-height: 32px;
  22.             position: relative;
  23.             margin: 3px 0;
  24.             counter-increment: nums;
  25.             padding-left: 30px;
  26.             overflow: hidden;
  27.             word-wrap: normal !important;
  28.             white-space: nowrap;
  29.             text-overflow: ellipsis
  30.         }
  31.         .hot-list-article li a {
  32.             color: #787977
  33.         }
  34.         .hot-list-article li:before {
  35.             color: #000;
  36.             width: 22px;
  37.             height: 22px;
  38.             line-height: 22px;
  39.             text-align: center;
  40.             content: counter(nums, decimal);
  41.             position: absolute;
  42.             left: 0;
  43.             top: 5px;
  44.             border-radius: 100%;
  45.             background-color: #edefee;
  46.             text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
  47.             font-family: SourceCodeProRegular, Menlo, Monaco, Consolas, "Courier New", monospace, 'Helvetica Neue', Arial, sans-serif
  48.         }
  49.         /*以上就是一个稍微好看的有编号的li列表 */
  50.         /*加上以下之后,排名前三的数据编号就添加了编号颜色,更好看*/
  51.         .hot-list-article li:first-child:before,
  52.         .hot-list-article li:nth-child(2):before,
  53.         .hot-list-article li:nth-child(3):before {
  54.             color: #fff;
  55.             text-shadow: none
  56.         }
  57.         .hot-list-article li:first-child:before {
  58.             background-color: #e24d46
  59.         }
  60.         /*第1行的行号样式*/
  61.         .hot-list-article li:nth-child(2):before {
  62.             background-color: #2ea7e0
  63.         }
  64.         /*第2行的行号样式*/
  65.         .hot-list-article li:nth-child(3):before {
  66.             background-color: #6bc30d
  67.         }
  68.         /*第3行的行号样式*/
  69.         .hot-list-article li a:hover {
  70.             text-decoration: underline;
  71.             color: #6bc30d
  72.         }
  73.         /*鼠标移过更好看*/
  74.     </style>
  75. </head>
  76. <body>
  77.     <div class="other-item">
  78.         <h5 class="other-item-title">热门文章</h5>
  79.         <div class="inner">
  80.             <ul class="hot-list-article">
  81.                 <li> <a href="/Blog/Read/9">SpringBoot 入门爬虫项目实战</a></li>
  82.                 <li> <a href="/Blog/Read/12">SpringBoot 2.x 教你快速入门</a></li>
  83.                 <li> <a href="/Blog/Read/13">java学习路线</a></li>
  84.                 <li> <a href="/Blog/Read/4">基于SpringBoot+JWT+Redis跨域单点登录的实现</a></li>
  85.                 <li> <a href="/Blog/Read/7">SpringBoot 中如何使用SwaggerAPI接口文档?</a></li>
  86.                 <li> <a href="/Blog/Read/11">小白轻松入门Redis</a></li>
  87.                 <li> <a href="/Blog/Read/14">微信一键登录功能的实现</a></li>
  88.                 <li> <a href="/Blog/Read/8">NPOI导入导出Excel</a></li>
  89.             </ul>
  90.         </div>
  91.     </div>
  92. </body>
  93. </html>
复制代码
vue文件

vue2 中实现
  1. <template>
  2.   <div class="other-item">
  3.     <h5 class="other-item-title">热门文章</h5>
  4.     <div class="inner">
  5.       <ul class="hot-list-article">
  6.         <li v-for="(item, i) in data" :key="i">
  7.           {{ item.title }}
  8.         </li>
  9.       </ul>
  10.     </div>
  11.   </div>
  12. </template>
  13. <script>
  14. export default {
  15.   data() {
  16.     return {
  17.       data: [
  18.         { title: "SpringBoot 入门爬虫项目实战" },
  19.         { title: "java学习路线" },
  20.         { title: "基于SpringBoot+JWT+Redis跨域单点登录的实现" },
  21.         { title: "SpringBoot 中如何使用SwaggerAPI接口文档?" },
  22.         { title: "小白轻松入门Redis" },
  23.         { title: "微信一键登录功能的实现" },
  24.         { title: "NPOI导入导出Excel" },
  25.       ],
  26.     };
  27.   },
  28.   created() {},
  29.   methods: {},
  30. };
  31. </script>
  32. <style lang="scss" scoped>
  33. ul {
  34.   li {
  35.     text-align: left;
  36.     font-size: 16px;
  37.     cursor: pointer;
  38.     &:hover {
  39.       color: #2ea7e0;
  40.     }
  41.   }
  42. }
  43. .other-item-title {
  44.   margin: 10px 20px;
  45.   padding: 5px;
  46.   line-height: 30px;
  47.   font-weight: 400;
  48.   border-bottom: 1px solid #e8e9e7;
  49.   color: #383937;
  50.   position: relative;
  51.   font-size: 18px;
  52. }
  53. .other-item .inner {
  54.   margin: 0 20px;
  55.   padding-bottom: 10px;
  56. }
  57. .inner .hot-list-article li {
  58.   display: block;
  59.   line-height: 32px;
  60.   position: relative;
  61.   margin: 3px 0;
  62.   counter-increment: nums;
  63.   padding-left: 30px;
  64.   overflow: hidden;
  65.   word-wrap: normal !important;
  66.   white-space: nowrap;
  67.   text-overflow: ellipsis;
  68. }
  69. .hot-list-article li a {
  70.   color: #787977;
  71. }
  72. .hot-list-article li:before {
  73.   color: #000;
  74.   width: 22px;
  75.   height: 22px;
  76.   line-height: 22px;
  77.   text-align: center;
  78.   content: counter(nums, decimal);
  79.   position: absolute;
  80.   left: 0;
  81.   top: 5px;
  82.   border-radius: 100%;
  83.   background-color: #edefee;
  84.   text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  85.   font-family: SourceCodeProRegular, Menlo, Monaco, Consolas, "Courier New",
  86.     monospace, "Helvetica Neue", Arial, sans-serif;
  87. }
  88. /*以上就是一个稍微好看的有编号的li列表 */
  89. /*加上以下之后,排名前三的数据编号就添加了编号颜色,更好看*/
  90. .hot-list-article li:first-child:before,
  91. .hot-list-article li:nth-child(2):before,
  92. .hot-list-article li:nth-child(3):before {
  93.   color: #fff;
  94.   text-shadow: none;
  95. }
  96. .hot-list-article li:first-child:before {
  97.   background-color: #e24d46;
  98. }
  99. /*第1行的行号样式*/
  100. .hot-list-article li:nth-child(2):before {
  101.   background-color: #2ea7e0;
  102. }
  103. /*第2行的行号样式*/
  104. .hot-list-article li:nth-child(3):before {
  105.   background-color: #6bc30d;
  106. }
  107. /*第3行的行号样式*/
  108. .hot-list-article li a:hover {
  109.   text-decoration: underline;
  110.   color: #6bc30d;
  111. }
  112. /*鼠标移过更好看*/
  113. </style>
复制代码
参考文章:ul好看的li列表样式
放工~

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

饭宝

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表