赞
踩
先发图,再说话:
按钮是好几种颜色的背景色组成的,使用css的话,应该会有几个不同颜色的层,在按钮后面移动。每个层互相叠加,大概还会用到图片混合模式产生了更多的叠加的颜色,然后边缘过渡的话,就是用模糊滤镜了。
<button class="base">浮光掠影</button>
- /* 颜色定义在这里 */
- :root{
- --main-bg-color: #333;
- --color:#000;
- --bg: #000000;
- --clr-1: #00ccff;
- --clr-2: #33ff8c;
- --clr-3: #ffcc00;
- --clr-4: #e54cff;
- --clr-5: #ffcc00;
- --blur: 1.2rem;
- }
-
- button{
- margin: 0.3em;
- outline: 0;
- border: none;
- }
- .base{
- position: relative;
- padding: 1rem 3rem; /* 用 padding 撑起按钮的宽度和高度 ,并确保了按钮文字水平方向居中 */
- font-family: "微软雅黑", sans-serif;
- font-size: 1.5rem;
- line-height: 1.5rem; /* 行高和字号大小相等,可以实现按钮文字在按钮内垂直居中 */
- font-weight:700;
- color: var(--color); /* 文字颜色为预定义的前景色 */
- cursor: pointer; /* 鼠标移动到按钮上时候的形状:手型 */
- user-select: none; /* 让用户不能选择按钮上的文字 */
- white-space: nowrap; /* 避免英文单词间的空格导致文字换行 */
- border-radius: 2rem;
- text-decoration: none;
- text-transform:uppercase; /* 字母自动修正为大写 */
- transition: all .5s; /* 按钮响应动画效果的持续时间 */
- margin: 1.5rem 2rem;
- }
先给按钮打个补丁:
- .base{
- overflow: hidden;
- }
-
- .base::before{
- content: "";
- position: absolute;
- width: 100%;
- height:100%;
- top:0;
- left:0;
- border-radius: 2rem;
- box-shadow: 8px 8px 10px 0 rgba( 66, 46,168, 0.9),-1px -1px 1px 0 rgba(207,189,245, 0.2),inset -1px 0px 0px 0 rgba( 255,255,255, 0.4),inset -1px 0px 10px 0 rgba( 255,255,255, 0.6),inset 1px 1px 0px 0 rgba( 255,255,255, 0.5);
- z-index: 4;
- }
接下来,我们要修改按钮的html结构:
- <button class="base" >浮光掠影
- <span cl
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。