鱼C论坛

 找回密码
 立即注册
查看: 1622|回复: 1

[作品展示] 【CSS】五个丝滑的按钮

[复制链接]
发表于 2022-1-25 19:01:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 ckblt 于 2022-1-25 19:00 编辑

纯HTML5+CSS3做成的五个丝滑的按钮~

  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3.   <head>
  4.     <meta charset="UTF-8" />
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7.     <title>五个丝滑的按钮!</title>

  8.     <style>
  9.       * {
  10.         margin: 0;
  11.         padding: 0;
  12.       }

  13.       #app {
  14.         display: flex;
  15.         justify-content: center;
  16.         align-items: center;
  17.         min-height: 100vh;
  18.         flex-direction: column;
  19.       }

  20.       #btn1,
  21.       #btn2,
  22.       #btn3,
  23.       #btn4,
  24.       #btn5 {
  25.         display: block;
  26.         margin: 30px;
  27.         font-size: 20px;
  28.       }

  29.       #btn1 {
  30.         width: 120px;
  31.         height: 60px;
  32.         transition: color 0.2s, background-color 0.2s, font-size 0.2s,
  33.           border 0.2s;
  34.         border: 0;
  35.         border-radius: 999px;
  36.         background-color: #000;
  37.         color: #fff;
  38.       }
  39.       #btn1:hover {
  40.         background-color: #fff;
  41.         border: solid 3px #000;
  42.         color: #000;
  43.         font-size: 23px;
  44.       }
  45.       #btn1:hover:active {
  46.         font-size: 19px;
  47.         border: solid 7px #000;
  48.         background-color: #bbb;
  49.       }

  50.       #btn2 {
  51.         width: 120px;
  52.         height: 60px;
  53.         transition: color 0.2s, border 0.2s, background-color 0.2s,
  54.           font-size 0.2s, border 0.2s;
  55.         border: 0;
  56.         border-radius: 999px;
  57.         background-color: #000;
  58.         color: #fff;
  59.       }
  60.       #btn2:hover {
  61.         background-color: #aaa;
  62.         border: solid 3px #000;
  63.         color: #000;
  64.         font-size: 23px;
  65.       }
  66.       #btn2:hover:active {
  67.         font-size: 25px;
  68.         border: solid 7px #000;
  69.         background-color: #ddd;
  70.       }

  71.       #btn3 {
  72.         width: 120px;
  73.         height: 60px;
  74.         transition: color 0.2s, border 0.2s, background-color 0.2s,
  75.           font-size 0.2s, border 0.2s;
  76.         border: 0;
  77.         border-radius: 999px;
  78.         background-color: #000;
  79.         color: #fff;
  80.       }
  81.       #btn3:hover {
  82.         background-color: #bbb;
  83.         border: solid 7px #000;
  84.         color: #000;
  85.         font-size: 22px;
  86.       }
  87.       #btn3:hover:active {
  88.         font-size: 25px;
  89.         border: solid 5px #000;
  90.         background-color: #ddd;
  91.       }

  92.       #btn4 {
  93.         width: 120px;
  94.         height: 60px;
  95.         filter: blur(0);
  96.         transition: width 0.2s, height 0.2s, color 0.2s, border 0.2s,
  97.           background-color 0.2s;
  98.         border: 0;
  99.         border-radius: 999px;
  100.         background-color: #000;
  101.         color: #fff;
  102.       }
  103.       #btn4:hover {
  104.         width: 130px;
  105.         height: 70px;
  106.         background-color: #fff;
  107.         border: solid 3px #000;
  108.         color: #000;
  109.       }
  110.       #btn4:hover:active {
  111.         width: 110px;
  112.         height: 50px;
  113.         border: solid 3px #000;
  114.         background-color: #bbb;
  115.       }

  116.       #btn5 {
  117.         width: 120px;
  118.         height: 60px;
  119.         filter: blur(0);
  120.         transition: width 0.2s, height 0.2s, color 0.2s, border 0.2s,
  121.           background-color 0.2s;
  122.         border: 0;
  123.         border-radius: 999px;
  124.         background-color: #000;
  125.         color: #fff;
  126.       }
  127.       #btn5:hover {
  128.         width: 110px;
  129.         height: 50px;
  130.         background-color: #fff;
  131.         border: solid 3px #000;
  132.         color: #000;
  133.       }
  134.       #btn5:hover:active {
  135.         width: 130px;
  136.         height: 70px;
  137.         border: solid 3px #000;
  138.         background-color: #bbb;
  139.       }
  140.     </style>
  141.   </head>
  142.   <body>
  143.     <div id="app">
  144.       <h1>五个丝滑的按钮</h1>
  145.       <h3>By Ckblt</h3>
  146.       <button id="btn1">button1</button>
  147.       <button id="btn2">button2</button>
  148.       <button id="btn3">button3</button>
  149.       <button id="btn4">button4</button>
  150.       <button id="btn5">button5</button>
  151.       <p>注:由于 button4 和 button5 会变大小,不建议使用</p>
  152.     </div>
  153.   </body>
  154. </html>
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-1-26 22:04:20 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-30 17:16

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表