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 相关文章推荐
详解如何在css中引入自定义字体(font-face)
May 17 HTML / CSS
CSS3实现可翻转的hover效果
May 23 HTML / CSS
2分钟教你实现环形/扇形菜单(基础版)
Jan 15 HTML / CSS
html+css3实现的登录界面
Dec 09 HTML / CSS
js实现移动端H5页面手指滑动刻度尺功能
Nov 16 HTML / CSS
HTML5教程之html 5 本地数据库(Web Sql Database)
Apr 03 HTML / CSS
HTML5中的音频和视频媒体播放元素小结
Jan 29 HTML / CSS
HTML5拖拽的简单实例
May 30 HTML / CSS
HTML5实现音频和视频嵌入的方法
Aug 22 HTML / CSS
iframe跨域的几种常用方法
Nov 11 HTML / CSS
HTML中table表格拆分合并(colspan、rowspan)
Apr 07 HTML / CSS
css中:last-child不生效的解决方法
Aug 05 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
提升PHP执行速度全攻略(上)
2006/10/09 PHP
使用swoole扩展php websocket示例
2014/02/13 PHP
PHP+MySQL实现无极限分类栏目的方法
2015/12/23 PHP
thinkPHP5.0框架URL访问方法详解
2017/03/18 PHP
php 判断页面或图片是否经过gzip压缩的方法
2017/04/05 PHP
php设计模式之享元模式分析【星际争霸游戏案例】
2020/03/23 PHP
jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist生成客户端HTML标签后的value和text值
2010/06/28 Javascript
Chrome下ifame父窗口调用子窗口的问题示例探讨
2014/03/17 Javascript
JS中自定义定时器让它在某一时刻执行
2014/09/02 Javascript
Vuejs第十篇之vuejs父子组件通信
2016/09/06 Javascript
详解jQuery事件
2017/01/13 Javascript
js每隔两秒输出数组中的一项(实例)
2017/05/28 Javascript
AngularJS ng-repeat指令及Ajax的应用实例分析
2017/07/06 Javascript
js实现本地图片文件拖拽效果
2017/07/18 Javascript
Vue的路由动态重定向和导航守卫实例
2018/03/17 Javascript
详解在Python程序中使用Cookie的教程
2015/04/30 Python
关于Python面向对象编程的知识点总结
2017/02/14 Python
详解Python中where()函数的用法
2018/03/27 Python
python数字图像处理实现直方图与均衡化
2018/05/04 Python
Python闭包思想与用法浅析
2018/12/27 Python
Python爬虫实现selenium处理iframe作用域问题
2021/01/27 Python
CSS3下的渐变文字效果实现示例
2018/03/02 HTML / CSS
CSS3关于z-index不生效问题的解决
2020/02/19 HTML / CSS
味多美官网:蛋糕订购,100%使用天然奶油
2017/11/10 全球购物
《四季》教学反思
2014/04/08 职场文书
超市促销活动总结
2014/07/01 职场文书
反四风对照检查材料思想汇报
2014/09/16 职场文书
个人委托书怎么写
2014/09/17 职场文书
内乡县衙导游词
2015/02/05 职场文书
雨雪天气温馨提示
2015/07/15 职场文书
客户答谢会致辞
2015/07/30 职场文书
2016新教师培训心得体会范文
2016/01/08 职场文书
创业计划书之婴幼儿游泳馆
2019/09/11 职场文书
python中的getter与setter你了解吗
2022/03/24 Python
Window server 2012 R2 AD域的组策略相关设置
2022/04/28 Servers
Zabbix对Kafka topic积压数据监控的问题(bug优化)
2022/07/07 Servers