【css+js】彩色书签

 

 点击后,书签就会慢慢消失,主要依靠css动画实现,

代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    body {
      padding: 0;
      margin: 0;
      background-color: #181857;
      height: 100vh;
      overflow: hidden;
    }

    li.hide {
      opacity: 0;
      transition: opacity ease-in 1s;
    }

    li {

      background-color: #FFFFFFCC;
      color: #FFF;
      border-radius: 5px;
      height: 22px;
      list-style: none;
      text-align: right;
      position: absolute;
      left: 30px;
      top: calc(50vh - 22px);
      width: 70%;
      opacity: 1;
      transition: transform ease-in 1s, opacity ease-in .5s, background-color ease-in .8s;
      transform-origin: left center;
      padding: 10px 50px 10px 10px;
    }
    li:hover {
      filter: brightness(40%);
    }
    ul {
      padding-inline-start: 0;
      padding-inline-end: 0;
      marker: none;
      height: 100vh;
      overflow: hidden;
      margin: 0;
      user-select: none;
    }

    li:nth-child(1) {
      transform: rotate(-80deg);
      background-color: rgba(245, 71, 71, 0.8);
    }

    li:nth-child(2) {
      transform: rotate(-60deg);
      background-color: rgba(245, 144, 71, 0.8);
    }

    li:nth-child(3) {
      transform: rotate(-40deg);
      background-color: rgba(245, 196, 71, 0.8);
    }

    li:nth-child(4) {
      transform: rotate(-20deg);
      background-color: rgba(103, 245, 71, 0.8);
    }

    li:nth-child(5) {
      transform: rotate(0deg);
      background-color: rgba(71, 245, 230, 0.8);
    }

    li:nth-child(6) {
      transform: rotate(20deg);
      background-color: rgba(71, 120, 245, 0.8);
    }

    li:nth-child(7) {
      transform: rotate(40deg);
      background-color: rgba(129, 71, 245, 0.8);
    }

    li:nth-child(8) {
      transform: rotate(60deg);
      background-color: rgba(207, 71, 245, 0.8);
    }

    li:nth-child(n+9) {
      opacity: 0;
      /*background-color: red;*/
      transform: rotate(90deg);
    }
  </style>
  <script>

    let dlist = [
      'meine',
      'hello',
      'is',
      'var',
      'let',
      'laugh',
      'many',
      'child',
      'lightning'
    ]
    window.onload = () => {
      let ul = document.querySelector('ul')
      let k = dlist.length
      let lil = []
      for (let i = 0; i < 100; i++) {
        let v = i % k
        let str = dlist[v]
        let li = document.createElement('li')
        li.innerText = str
        li.addEventListener('click', (e) => {
          e.target.remove()
        })
        ul.append(li)
        lil.push(li)
      }

    }
  </script>
</head>
<body>
<ul>

</ul>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值