html+css 边框滑动按钮效果

前言:哈喽,大家好,今天给大家分享html+css 绚丽效果!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕

支持一下

效果

html+css 边框滑动按钮效果

原理解析

1.给每一个按钮添加一个hover效果,并初始化一个transition过渡动画效果
2.当按钮上有鼠标时,hover效果触发,运行transition过渡动画效果。
触发hover

3.具体的变换参数,直接看代码,可以一键复制,查看效果

上代码,可以直接复制使用

目录

yyml

html

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>html+css 边框滑动按钮效果</title>
    <link rel="stylesheet" href="./style.css">
</head>

<body>
<h1 style="text-align: center;color:#fff;margin-bottom: 50px;padding-top: 50px">html+css 边框滑动按钮效果</h1>
    <div class="container">
        <button class="btn">点赞</button>
        <button class="btn">关注</button>
        <button class="btn">评论</button>
        <button class="btn">转发</button>
    </div>
</body>

</html>

css

*{
    /* 初始化 取消页面元素的内外边距 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;

    /* 自定义属性 背景颜色 可通过var函数调用 */
    --bgc: #353b48;
    background-color: var(--bgc);
}
.container{
    /* 弹性布局 */
    display: flex;
    /* 水平排列 */
    flex-direction: row;
    /* 允许换行 */
    flex-wrap: wrap;
    justify-content: center;

}
.container .btn{
    width: 200px;
    height: 60px;
    background: none;
    border: 4px solid;
    color: var(--c);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    margin: 20px;
    /* 相对定位 */
    position: relative;
}
.container .btn::before,
.container .btn::after{
    content: "";
    /* 绝对定位 */
    position: absolute;
    width: 14px;
    height: 4px;
    /* 颜色与背景色同色 */
    background-color: var(--bgc);
    /* 沿X轴倾斜30度 */
    transform: skewX(30deg);
    /* 动画过渡 */
    transition: 0.4s linear;
}
.container .btn::before{
    top: -4px;
    left: 10%;
}
.container .btn::after{
    bottom: -4px;
    right: 10%;
}
.container .btn:hover::before{
    left: 80%;
}
.container .btn:hover::after{
    right: 80%;
}
/* 接下来设置每一个按钮的自定义颜色属性--c */
.container .btn:nth-child(1){
    --c: #4ad3e2;
}
.container .btn:nth-child(2){
    --c: #93edd4;
}
.container .btn:nth-child(3){
    --c: #f9cb8f;
}
.container .btn:nth-child(4){
    --c: #ffb1a3;
}

到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~💕

整理不易,点赞关注宝码香车

更多专栏订阅推荐:
👍 html+css+js 绚丽效果
💕 vue
✈️ Electron
⭐️ js
📝 字符串
✍️ 时间对象(Date())操作

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宝码香车

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值