css 通知气泡+左右跳动效果

今天在做个人中心的时候用到了通知并使用了css动画+气泡效果,记录下。先上效果图
在这里插入图片描述
通知图标+通知数量(html)

<transition name="slide-fade">
   <i class="iconfont icon-notice" @click="showNotice=!showNotice"></i> <--通知图标 !-->
</transition>
<transition name="slide-fade">
    <span class="notice-box" v-if="noticeList.length>0" @click="showNotice=!showNotice">{{noticeList.length}}</span> <--通知数量 !-->
</transition>

通知列表(html)

<div class="notice" v-show="showNotice" v-for="(item,index) in noticeList" :key="index">
<ul v-if="noticeList.length>0">
  <li>
    <p><span>{{index+1}}.</span> {{item.title}}</p>
    <p> {{item.detail}}</p>
    <p> {{item.from}}<span class="f-r">{{item.add_time|getDateTime}}</span></p>
  </li>
</ul>
<ul v-else>
  <li>
    <p> 没有新的通知</p>
  </li>
</ul>
</div>
//通知图标用的阿里云iconfont这个需要自己去做
.icon-round::before{content: '';width: 5px;height: 5px;display: inline-block;background-color: red;border-radius: 50%;} //通知数量图标
.notice{position: absolute;right: 64px;width: 190px;background-color: rgb(255, 255, 255);font-size: 12px;top: 27px;padding: 10px;max-height: calc(100vh - 80px);box-shadow: 0px 0px 9px #46d5ff;z-index: 99;border-radius: 6px;animation: move 0.5s 0s;}
.notice:after{content: "";width: 0;height: 0;border-width: 0 7px 15px;border-style: solid;border-color: transparent transparent #fff;position: absolute;top: -6px;right: -6px;transform: rotate(45deg);} //右上角指向标
.notice li{padding-bottom: 6px;margin-bottom: 6px;border-bottom: 1px solid #eee;}
.notice li p{position: relative;padding-left: 18px;}
.notice li p:first-child {font-size: 14px;color: #03b8ee;}
.notice li p:first-child span{position: absolute;left: 0;line-height: 24px;color: #03b8ee;font-size: 16px;width: 18px;;text-align: left;}
.notice li p:nth-child(2) {font-size: 10px;color:  #03b8ee;margin: 6px 0;line-height: 16px;}
.notice li p:nth-child(3) {font-size: 10px;color:  #ddd;}

@keyframes move{ //左右跳动动画
25%{transform:translateX(4px);}
50%{transform:translateX(-4px);}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值