前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >纯CSS实现的一个对角线填充颜色的按钮悬停动效

纯CSS实现的一个对角线填充颜色的按钮悬停动效

作者头像
itclanCoder
发布2023-09-14 17:17:05
1970
发布2023-09-14 17:17:05
举报
文章被收录于专栏:itclanCoder

示例代码

代码语言:javascript
复制
<template>
   <div class="example-duijiaobtn">
        <div class="button_container">
           <button class="btn"><span>悬停动效</span></button>
        </div>
   </div>
</template>
<style scoped>
.example-duijiaobtn {
    margin: 0;
    height: 100%;
    background-image: linear-gradient(to top, #d9afd9 0%, #97d9e1 100%);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}
.button_container {
    position: absolute;
    left: 0;
    right: 0;
    top: 30%;
}
.button_container p {
    font-family: 'Amatic SC', cursive;
    text-align: center;
    font-size: 35px;
}
.btn {
    border: none;
    display: block;
    text-align: center;
    cursor: pointer;
    text-transform: uppercase;
    outline: none;
    overflow: hidden;
    position: relative;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    background-color: #222;
    padding: 17px 60px;
    margin: 0 auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.20);
}
.btn span {
    position: relative;
    z-index: 1;
}
.btn:after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 490%;
    width: 140%;
    background: #78c7d2;
    -webkit-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;
    -webkit-transform: translateX(-98%) translateY(-25%) rotate(45deg);
    transform: translateX(-98%) translateY(-25%) rotate(45deg);
}
.btn:hover:after {
    -webkit-transform: translateX(-9%) translateY(-25%) rotate(45deg);
    transform: translateX(-9%) translateY(-25%) rotate(45deg);
}
</style>
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-08-07 00:00,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 itclanCoder 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档