按钮图标

纯CSS3手绘风格卡通按钮设计效果

阿里云


这是一组非常有趣的纯 CSS3 手绘风格卡通按钮设计效果。这组手绘风格按钮共 6 种不同的效果,它们以手绘涂鸦的方式,以不同的按钮边框线条宽度和虚线来构成按钮,效果非常不错。

HTML 结构

该手绘风格卡通按钮的 HTML 结构就是使用一个按钮<button>元素,配以不同的 class 类来实现不同的手绘风格按钮。

也想出现在这里?联系我们
创客主机
  1. <section>
  2.   <button class='lined thick'>Lined Thick</button>
  3.   <button class='dotted thick'>Dotted Thick</button>
  4.   <button class='dashed thick'>Dashed Thick</button>
  5. </section>

CSS 样式

在这个 DEMO 中,整个页面以 flexbox 进行布局。页面字体使用的是一种手绘风格的谷歌字体。

  1. @import url(https://fonts.googleapis.com/css?family=Patrick+Hand+SC);
  2. html, body {
  3.   width: 100%;
  4.   min-height: 100%;
  5.   margin: 0;
  6.   display: -webkit-box;
  7.   display: -webkit-flex;
  8.   display: -ms-flexbox;
  9.   display: flex;
  10.   -webkit-box-orient: vertical;
  11.   -webkit-box-direction: normal;
  12.   -webkit-flex-direction: column;
  13.       -ms-flex-direction: column;
  14.           flex-direction: column;
  15.   -webkit-box-pack: center;
  16.   -webkit-justify-content: center;
  17.       -ms-flex-pack: center;
  18.           justify-content: center;
  19.   background: #F0F0D8;
  20.   font-family: 'Patrick Hand SC', cursive;
  21. }
  22. html section, body section {
  23.   display: -webkit-box;
  24.   display: -webkit-flex;
  25.   display: -ms-flexbox;
  26.   display: flex;
  27.   -webkit-box-orient: horizontal;
  28.   -webkit-box-direction: normal;
  29.   -webkit-flex-direction: row;
  30.       -ms-flex-direction: row;
  31.           flex-direction: row;
  32.   -webkit-box-pack: center;
  33.   -webkit-justify-content: center;
  34.       -ms-flex-pack: center;
  35.           justify-content: center;
  36.   width: 100%;
  37.   min-height: 100%;
  38.   margin-bottom: 3rem;
  39. }

所有的按钮的背景色都设置为透明,通过 padding 来设置按钮的尺寸,并为按钮设置一些阴影效果和圆角效果。还为按钮指定 0.5 秒的 ease 效果的过渡动画。

  1. html section button, body section button {
  2.   -webkit-align-self: center;
  3.       -ms-flex-item-align: center;
  4.           align-self: center;
  5.   background: transparent;
  6.   padding: 1rem 1rem;
  7.   margin: 0 1rem;
  8.   -webkit-transition: all .5s ease;
  9.   transition: all .5s ease;
  10.   color: #41403E;
  11.   font-size: 2rem;
  12.   letter-spacing: 1px;
  13.   outline: none;
  14.   box-shadow: 20px 38px 34px -26px rgba(0, 0, 0, 0.2);
  15.   border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  16. }

上面的圆角设置等价于下面的代码:

  1. border-top-left-radius: 255px 15px;
  2. border-top-right-radius: 15px 225px;
  3. border-bottom-right-radius: 225px 15px;
  4. border-bottom-left-radius:15px 255px;

然后分别为 6 种不同的手绘风格按钮的指定各自的边框样式。

  1. html section button.lined.thick, body section button.lined.thick {
  2.   border: solid 7px #41403E;
  3. }
  4. html section button.dotted.thick, body section button.dotted.thick {
  5.   border: dotted 5px #41403E;
  6. }
  7. html section button.dashed.thick, body section button.dashed.thick {
  8.   border: dashed 5px #41403E;
  9. }
  10. html section button.lined.thin, body section button.lined.thin {
  11.   border: solid 2px #41403E;
  12. }
  13. html section button.dotted.thin, body section button.dotted.thin {
  14.   border: dotted 2px #41403E;
  15. }
  16. html section button.dashed.thin, body section button.dashed.thin {
  17.   border: dashed 2px #41403E;
  18. }

在鼠标滑过按钮时,修改按钮的阴影效果。

  1. html section button:hover, body section button:hover {
  2.   box-shadow: 2px 8px 4px -6px rgba(0, 0, 0, 0.3);
  3. }

最后,使用媒体查询来制作在小屏幕上的布局效果。

  1. @media (max-width: 620px) {
  2.   body h1 {
  3.     margin-top: 2rem;
  4.   }
  5.   body section {
  6.     display: -webkit-box;
  7.     display: -webkit-flex;
  8.     display: -ms-flexbox;
  9.     display: flex;
  10.     -webkit-box-orient: vertical;
  11.     -webkit-box-direction: normal;
  12.     -webkit-flex-direction: column;
  13.         -ms-flex-direction: column;
  14.             flex-direction: column;
  15.     -webkit-box-pack: center;
  16.     -webkit-justify-content: center;
  17.         -ms-flex-pack: center;
  18.             justify-content: center;
  19.     margin-bottom: 1rem;
  20.   }
  21.   body section button {
  22.     -webkit-align-self: center;
  23.         -ms-flex-item-align: center;
  24.             align-self: center;
  25.     margin-bottom: 2rem;
  26.   }
  27. }

纯 CSS3 手绘风格卡通按钮设计效果

已有 521 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!