CSS3 制作的彩虹按钮样式


Posted in HTML / CSS onApril 11, 2021

实现效果:

CSS3 制作的彩虹按钮样式

实现代码:

html

<div class="buttons">
  <h1>Simple hover effects with <code>box-shadow</code></h1>
  <button class="fill">Fill In</button>
  <button class="pulse">Pulse</button>
  <button class="close">Close</button>
  <button class="raise">Raise</button>
  <button class="up">Fill Up</button>
  <button class="slide">Slide</button>
  <button class="offset">Offset</button>
</div>

CSS

/*
  https://developer.mozilla.org/en/docs/Web/CSS/box-shadow
  box-shadow: [inset?] [top] [left] [blur] [size] [color];

  Tips:
    - We're setting all the blurs to 0 since we want a solid fill.
    - Add the inset keyword so the box-shadow is on the inside of the element
    - Animating the inset shadow on hover looks like the element is filling in from whatever side you specify ([top] and [left] accept negative values to become [bottom] and [right])
    - Multiple shadows can be stacked
    - If you're animating multiple shadows, be sure to keep the same number of shadows so the animation is smooth. Otherwise, you'll get something choppy.
*/
.fill:hover,
.fill:focus {
  box-shadow: inset 0 0 0 2em var(--hover);
}

.pulse:hover,
.pulse:focus {
  -webkit-animation: pulse 1s;
          animation: pulse 1s;
  box-shadow: 0 0 0 2em rgba(255, 255, 255, 0);
}

@-webkit-keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--hover);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--hover);
  }
}
.close:hover,
.close:focus {
  box-shadow: inset -3.5em 0 0 0 var(--hover), inset 3.5em 0 0 0 var(--hover);
}

.raise:hover,
.raise:focus {
  box-shadow: 0 0.5em 0.5em -0.4em var(--hover);
  transform: translateY(-0.25em);
}

.up:hover,
.up:focus {
  box-shadow: inset 0 -3.25em 0 0 var(--hover);
}

.slide:hover,
.slide:focus {
  box-shadow: inset 6.5em 0 0 0 var(--hover);
}

.offset {
  box-shadow: 0.3em 0.3em 0 0 var(--color), inset 0.3em 0.3em 0 0 var(--color);
}
.offset:hover, .offset:focus {
  box-shadow: 0 0 0 0 var(--hover), inset 6em 3.5em 0 0 var(--hover);
}

.fill {
  --color: #a972cb;
  --hover: #cb72aa;
}

.pulse {
  --color: #ef6eae;
  --hover: #ef8f6e;
}

.close {
  --color: #ff7f82;
  --hover: #ffdc7f;
}

.raise {
  --color: #ffa260;
  --hover: #e5ff60;
}

.up {
  --color: #e4cb58;
  --hover: #94e458;
}

.slide {
  --color: #8fc866;
  --hover: #66c887;
}

.offset {
  --color: #19bc8b;
  --hover: #1973bc;
}

button {
  color: var(--color);
  transition: 0.25s;
}
button:hover, button:focus {
  border-color: var(--hover);
  color: #fff;
}

body {
  color: #fff;
  background: #17181c;
  font: 300 1em "Fira Sans", sans-serif;
  justify-content: center;
  align-content: center;
  align-items: center;
  text-align: center;
  min-height: 100vh;
  display: flex;
}

button {
  background: none;
  border: 2px solid;
  font: inherit;
  line-height: 1;
  margin: 0.5em;
  padding: 1em 2em;
}

h1 {
  font-weight: 400;
}

code {
  color: #e4cb58;
  font: inherit;
}

以上就是CSS3 制作的彩虹按钮样式的详细内容,更多关于CSS3 按钮样式的资料请关注三水点靠木其它相关文章!

 
HTML / CSS 相关文章推荐
CSS3动画animation实现云彩向左滚动
May 09 HTML / CSS
CSS3中使用RGBa来调节透明度的教程
May 09 HTML / CSS
HTML5 FormData 方法介绍以及实现文件上传示例
Sep 12 HTML / CSS
html5中localStorage本地存储的简单使用
Jun 16 HTML / CSS
html5 分层屏幕适配的方法
Mar 16 HTML / CSS
canvas绘制文本内容自动换行的实现代码
Jan 14 HTML / CSS
HTML5 Canvas 起步(1) - 基本概念
May 12 HTML / CSS
html5+css3实现一款注册表单实例
Apr 17 HTML / CSS
HTML5 Canvas实现烟花绽放特效
Mar 02 HTML / CSS
HTML5实现多张图片上传功能
Mar 11 HTML / CSS
HTML5 localStorage使用总结
Feb 22 HTML / CSS
HTML5拖放API实现拖放排序的实例代码
May 11 HTML / CSS
CSS中em的正确打开方式详解
几款流行的HTML5 UI框架比较(小结)
css 中多种边框的实现小窍门
HTML中table表格拆分合并(colspan、rowspan)
HTML速写之Emmet语法规则的实现
使用Html+Css实现简易导航栏功能(导航栏遇到鼠标切换背景颜色)
Apr 07 #HTML / CSS
html+css 实现简易导航栏功能
Apr 07 #HTML / CSS
You might like
详解cookie验证的php应用的一种SSO解决办法
2017/10/20 PHP
PHP7内核之Reference详解
2019/03/14 PHP
javascript html 静态页面传参数
2009/04/10 Javascript
JavaScript 浮点数运算 精度问题
2009/10/06 Javascript
zeroclipboard复制到剪切板的flash
2010/08/04 Javascript
jQuery 幻灯片插件(带缩略图功能)
2011/01/24 Javascript
jquery网页回到顶部效果(图标渐隐,自写)
2014/06/16 Javascript
Express.JS使用详解
2014/07/17 Javascript
JavaScript中的值是按值传递还是按引用传递问题探讨
2015/01/30 Javascript
javascript生成img标签的3种实现方法(对象、方法、html)
2015/12/25 Javascript
实例详解ECMAScript5中新增的Array方法
2016/04/05 Javascript
jQuery实现在HTML文档加载完毕后自动执行某个事件的方法
2017/05/08 jQuery
基于模板引擎Jade的应用(详解)
2017/12/12 Javascript
React Form组件的实现封装杂谈
2018/05/07 Javascript
[43:33]EG vs Spirit Supermajor 败者组 BO3 第一场 6.4
2018/06/05 DOTA
Python类的基础入门知识
2008/11/24 Python
Python中的模块和包概念介绍
2015/04/13 Python
在Python中使用base64模块处理字符编码的教程
2015/04/28 Python
Python分支结构(switch)操作简介
2018/01/17 Python
pycharm恢复默认设置或者是替换pycharm的解释器实例
2018/10/29 Python
django 外键model的互相读取方法
2018/12/15 Python
python正则表达式匹配不包含某几个字符的字符串方法
2019/07/23 Python
django 配置阿里云OSS存储media文件的例子
2019/08/20 Python
利用python实现周期财务统计可视化
2019/08/25 Python
python可视化实现KNN算法
2019/10/16 Python
Python3 中作为一等对象的函数解析
2019/12/11 Python
python tkinter GUI绘制,以及点击更新显示图片代码
2020/03/14 Python
python 日志模块 日志等级设置失效的解决方案
2020/05/26 Python
Python 利用OpenCV给照片换底色的示例代码
2020/08/03 Python
使用Django的JsonResponse返回数据的实现
2021/01/15 Python
应届生个人求职信模板
2013/11/26 职场文书
企业财务经理岗位职责
2015/04/08 职场文书
学前教育见习总结
2015/06/23 职场文书
职场新人刚入职工作总结该怎么写?
2019/05/15 职场文书
Python 线程池模块之多线程操作代码
2021/05/20 Python
JPA 通过Specification如何实现复杂查询
2021/11/23 Java/Android