html+css 炫酷的流边按钮

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

文章目录

一、效果

二、原理解析

1.给每一个按钮添加一个hover效果,当鼠标移动上去时改变按钮的效果。

2.当按钮上有鼠标时,hover效果触发。

javascript 复制代码
/* 鼠标悬停时改变线条样式 */
.button:hover .shape {
    stroke: #06e6a0;
    stroke-width: 3;
    stroke-dasharray: 50 0;
    stroke-dashoffset: 0;
}

2.1stroke-dasharray介绍

2.2stroke-dashoffset介绍

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

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

目录

html

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>

<div class="container">
    <h1 style="text-align: center;color:#fff;margin-bottom: 50px;padding-top: 50px; text-shadow: 0 3px 3px #4c6ed3;">
        html+css 炫酷的流边按钮</h1>
    <div class="wrapper">
        <div class="button">
            <svg width="160" height="50">
                <rect class="shape" width="160" height="50"></rect>
                <div class="text">求点赞</div>
            </svg>
        </div>
        <div class="button">
            <svg width="160" height="50">
                <rect class="shape" width="160" height="50"></rect>
                <div class="text">求关注</div>
            </svg>
        </div>
        <div class="button">
            <svg width="160" height="50">
                <rect class="shape" width="160" height="50"></rect>
                <div class="text">求分享</div>
            </svg>
        </div>
    </div>


</div>
</body>

</html>

css

css 复制代码
* {
    margin: 0;
    padding: 0;
}

.container {
    /* 方便演示,居中显示 */
    height: 100vh;
    background-color: #2c3e50;
}

.wrapper {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.button {
    /* 相对定位 */
    position: relative;
    width: 160px;
    height: 50px;
    margin: 0 15px;
    cursor: pointer;
}

.shape {
    /* 取消填充 */
    fill: none;
    /* 定义一条线 */
    stroke: #009ffd;
    /* 线的厚度 */
    stroke-width: 6;
    /* 设置虚线:虚线长度 间距 */
    stroke-dasharray: 100 400;
    /* 虚线偏移量 */
    stroke-dashoffset: -240;
    /* 过渡效果 */
    transition: 1s ease;
}

.text {
    /* 绝对定位 居中 */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    letter-spacing: 2px;
}

/* 鼠标悬停时改变线条样式 */
.button:hover .shape {
    stroke: #06e6a0;
    stroke-width: 3;
    stroke-dasharray: 50 0;
    stroke-dashoffset: 0;
}

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

更多专栏订阅推荐:

👍 html+css+js 绚丽效果

💕 vue

✈️ Electron

⭐️ js

📝 字符串

✍️ 时间对象(Date())操作

相关推荐
影子落人间几秒前
已解决npm ERR! request to https://registry.npm.taobao.org/@vant%2farea-data failed
前端·npm·node.js
世俗ˊ25 分钟前
CSS入门笔记
前端·css·笔记
子非鱼92125 分钟前
【前端】ES6:Set与Map
前端·javascript·es6
6230_30 分钟前
git使用“保姆级”教程1——简介及配置项设置
前端·git·学习·html·web3·学习方法·改行学it
想退休的搬砖人39 分钟前
vue选项式写法项目案例(购物车)
前端·javascript·vue.js
加勒比海涛1 小时前
HTML 揭秘:HTML 编码快速入门
前端·html
啥子花道1 小时前
Vue3.4 中 v-model 双向数据绑定新玩法详解
前端·javascript·vue.js
麒麟而非淇淋1 小时前
AJAX 入门 day3
前端·javascript·ajax
茶茶只知道学习1 小时前
通过鼠标移动来调整两个盒子的宽度(响应式)
前端·javascript·css
清汤饺子1 小时前
实践指南之网页转PDF
前端·javascript·react.js