css添加hover让绝对定位元素过渡显现出来

.each_wrap {
  position: relative;
  transition: all 500ms ease;
  .active {
    background: #edf2fe;
  }
  .each_item {
    position: relative;
    height: 58px;
    padding-right: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    cursor: pointer;
  }
  .delIcon {
    display: none;
  }
  &:hover {
    background: #edf2fe;
    .delIcon {
      animation: hideIndex 0.3s;
      position: absolute;
      top: 20px;
      right: 12px;
      width: 14px;
      display: block;
      cursor: pointer;
    }
  }
}

@keyframes hideIndex {
  0% {
    opacity: 0;
    transform: translate(800px, 0);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0);
  }
}
            <div className={css.each_wrap}>
              <div
                className={`${css.each_item} ${index == catIdx ? css.active : null}`}
              >
                <div>{title}</div>
                <div>章节号:{chapterNo}</div>
              </div>
              <img
                src={DelIcon}
                onClick={() => delModalRef.current.openHandle(el)}
                className={css.delIcon}
              />
            </div>

利用animation使删除图标过度显现

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值