设为首页收藏本站随便看看 劰载中...
虚位以待,此位置招租
虚位以待,此位置招租
虚位以待,此位置招租
虚位以待,此位置招租
虚位以待,此位置招租
虚位以待,此位置招租
NexaHub聚合登录 阿里云服务器 99元/年 大流量卡 - 免开卡,免运费 172 - 大流量卡 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租
输入验证码,即可复制
扫描二维码输入:jiuge,即可获取验证码
只需要3秒时间
返回列表 发布新帖

[代码特效] HTML&CSS :移动端导航栏

16 0
发表于 6 天前 | 查看全部 阅读模式
这段代码通过纯CSS实现了一个水平排列的按钮组,每个按钮包含一个SVG图标。按钮在鼠标悬停时会轻微上移,增强用户体验。整体设计简洁美观,适合用于导航栏、工具栏或其他需要图标按钮的场景。
微信图片_20250309222857.gif

HTML&CSS
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公众号关注:前端Hardy</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #e8e8e8;
            overflow: hidden;
        }

        .container {
            display: flex;
            background-color: rgba(245, 73, 144);
            width: 250px;
            height: 40px;
            align-items: center;
            justify-content: space-around;
            border-radius: 10px;

        }

        .button {
            outline: 0 !important;
            border: 0 !important;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            transition: all ease-in-out 0.3s;
            cursor: pointer;
        }

        .button:hover {
            transform: translateY(-3px);
        }

        .icon {
            font-size: 20px;
        }
    </style>
</head>

<body>
    <div class="container">
        <button class="button">
            <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 1024 1024" stroke-width="0"
                fill="currentColor" stroke="currentColor" class="icon">
                <path
                    d="M946.5 505L560.1 118.8l-25.9-25.9a31.5 31.5 0 0 0-44.4 0L77.5 505a63.9 63.9 0 0 0-18.8 46c.4 35.2 29.7 63.3 64.9 63.3h42.5V940h691.8V614.3h43.4c17.1 0 33.2-6.7 45.3-18.8a63.6 63.6 0 0 0 18.7-45.3c0-17-6.7-33.1-18.8-45.2zM568 868H456V664h112v204zm217.9-325.7V868H632V640c0-22.1-17.9-40-40-40H432c-22.1 0-40 17.9-40 40v228H238.1V542.3h-96l370-369.7 23.1 23.1L882 542.3h-96.1z">
                </path>
            </svg>
        </button>
        <button class="button">
            <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" viewBox="0 0 24 24"
                stroke-width="2" fill="none" stroke="currentColor" class="icon">
                <path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" stroke-linejoin="round" stroke-linecap="round">
                </path>
            </svg>
        </button>
        <button class="button">
            <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" stroke-width="0"
                fill="currentColor" stroke="currentColor" class="icon">
                <path
                    d="M12 2.5a5.5 5.5 0 0 1 3.096 10.047 9.005 9.005 0 0 1 5.9 8.181.75.75 0 1 1-1.499.044 7.5 7.5 0 0 0-14.993 0 .75.75 0 0 1-1.5-.045 9.005 9.005 0 0 1 5.9-8.18A5.5 5.5 0 0 1 12 2.5ZM8 8a4 4 0 1 0 8 0 4 4 0 0 0-8 0Z">
                </path>
            </svg>
        </button>

        <button class="button">
            <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" stroke-linejoin="round"
                stroke-linecap="round" viewBox="0 0 24 24" stroke-width="2" fill="none" stroke="currentColor"
                class="icon">
                <circle r="1" cy="21" cx="9"></circle>
                <circle r="1" cy="21" cx="20"></circle>
                <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
            </svg>
        </button>
    </div>
</body>
</html>

HTML 结构

  • container:按钮组的容器,用于水平排列按钮。
  • button:定义一个按钮,包含SVG图标。
  • svg:定义按钮中的SVG图标,使用path定义图标形状。


CSS 样式

  • body:设置页面背景颜色、布局方式(居中对齐)和全屏高度。
  • .container:定义按钮组的样式,包括背景颜色、宽高、圆角和水平排列。
  • .button:定义按钮的样式,包括大小、圆角、背景颜色、鼠标悬停效果和过渡动画。
  • .button:hover:鼠标悬停时,按钮向上移动3像素,增强交互性。
  • .icon:定义SVG图标的样式,包括字体大小和颜色。

免责声明

本社区仅提供信息交流平台,帖子内容由用户自行发布,不代表社区立场。用户对发布内容负全责,包括版权、隐私、诽谤等,社区不承担因使用社区内容导致的损失。禁止发布侵权、隐私信息,发现侵权请联系我们。社区不负责第三方内容,用户因访问第三方内容产生的损失,社区不担责。用户须遵守规则和法律,不得发布违法、不当内容,违规内容将被删除。发表帖子即同意本声明,不同意请勿发帖。


特别提醒:网络空间并非法外之地,请广大用户自觉遵守法律法规,共同营造健康、文明、有序的网络环境。

本社区运营团队

联系我们: 如有疑问或发现违规行为,请联系管理员:kefu@foxccs.com

远方路灯明灭,银河倾斜,一斛星斗洒满天街。

回复

快捷回复: 经历想经历的,成为想成为的 - 九歌社区
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

jiubbs@126.com

网站内容来源于网络,版权争议与本站无关。
请在下载后的24小时内从您的设备中彻底删除上述内容。

  • QQ交流群
  • 添加微信客服
Copyright © 2004-2025 九歌社区 版权所有 All Rights Reserved.
关灯 在本版发帖
扫一扫添加微信客服
官方QQ交流群
手机扫一扫访问
返回顶部
快速回复 返回顶部 返回列表