css3怎样实现彩虹按钮的样式?
Admin 2021-10-12 群英技术资讯 1007 次浏览
这篇文章给大家分享css3制作按钮的内容,我们知道按钮的样式有很多,本文分享的是实现彩虹按钮的样式的实例,实现效果及代码如下,接下来跟随小编来了解看看吧。

<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>
/*
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怎样实现彩虹按钮的样式”的介绍啦,上述示例具有一定的借鉴价值,有需要的朋友可以参考学习,希望对大家有帮助,想要了解更多大家可以继续浏览群英网络其他相关的文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
由于最近在做一些边框按钮的阴影效果用到了box-shadow属性,发现这个阴影效果的css属性真的很值得学习,特地网上学习了一下box-shadow属性。 一.box-shadow的定义和语法 定义: box-shadow是css3新增的一个属性。在W3School里,定义box-shadow是向框添加一个
这篇文章主要介绍了canvas多重阴影发光效果实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
这篇文章主要介绍了详解iframe的src指向的内容不刷新的解决办法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
这篇文章主要介绍了html5 横向滑动导航栏的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
a标签定义一个圆角按钮并添加阴影效果该怎么添加CSS样式呢?可以先看下面这一段CSS代码: /*html代码*/aclass=btn-buy去淘宝下单/a/*对应的css代码*/style.btn-buy:hover{text-decoration:none;color:white;background-color:#FF2463}.btn-buy{-webkit-borde
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008