css3填充式进度条动画(CSS3样式linear-gradient的使用实例)
类别:Web前端 浏览量:2814
时间:2022-01-26 01:13:44 css3填充式进度条动画
CSS3样式linear-gradient的使用实例linear-gradient
1.linear-gradient是CSS3中新增的样式,主要用于颜色的渐变效果。
2.linear-gradient在不同内核下使用方式不同。
实用栗子(在Chrome下)
1.缺角效果
先看效果图
<li class="li1"> 这是内容 </li>
.li1 { width: 100px; height: 40px; line-height: 40px; background:linear-gradient(-135deg, transparent 15px, #162e48 0); color: #fff; padding: 5px 15px; text-align: center; margin-bottom: 30px; }
2.补角效果
先看效果图
.li2 { width: 100px; height: 40px; line-height: 40px; background:linear-gradient(-135deg, #f00 15px, #162e48 0); color: #fff; padding: 5px 15px; text-align: center; margin-bottom: 30px; }
只是在栗子1的基础上修改了linear-gradient,将transparent修改为#f00
3.带边框的效果
先看效果图
<li class="li3"> 这是内容 </li>
.li3 { width: 100px; height: 40px; line-height: 40px; background:linear-gradient(-135deg, #f00 15px, #162e48 0); color: #fff; padding: 5px 15px; text-align: center; margin-bottom: 30px; box-shadow: 0 0 1px 1px #fff inset; }
在栗子2的基础上增加了box-shadow,当然加边框可以有多种方式,可自行选择。
4.开关效果
效果图
<li class="li4"> <li class="li4-1">OFF</li> <li class="li4-2 active">ON</li> </li>
.li4 { width: 144px; height: 30px; line-height: 30px; background: #162e48; color: #FFF; text-align: center; margin-bottom: 30px; } .li4-1, .li4-2 { width: 86px; float: left; } .li4-1.active { margin-right: -28px; background:linear-gradient(-135deg, transparent 20px, #f00 0); } .li4-2.active { margin-left: -28px; background:linear-gradient(45deg, transparent 20px, #f00 0); }
最终效果可根据需要自行调整
5.在栗子3的基础上做到以下效果,单纯使用linear-gradient没有找到解决方法,如有方案,请在评论下给出方案。以下是其中一种解决方式
效果图
.li5 { width: 100px; height: 40px; line-height: 40px; background:linear-gradient(-135deg, #fff 15px, #162e48 0); color: #fff; padding: 5px 15px; text-align: center; box-shadow: 0 0 1px 1px #fff; margin-bottom: 30px; position: relative; } .li5:after { content: ' '; border: solid transparent; position: absolute; border-width: 12px; border-top-color: #000; border-right-color: #000; top: -2px; right: -2px; }
6.考虑到兼容性问题,可以通过:before和:after实现同样的效果,给出一个栗子
.li6 { width: 100px; height: 40px; line-height: 40px; background:#162e48; color: #fff; padding: 5px 15px; text-align: center; position: relative; border: 1px solid #fff; margin-bottom: 30px; } .li6:before { content: ' '; border: solid transparent; position: absolute; border-width: 15px; border-top-color: #fff; border-right-color: #fff; right: 0px; top: 0px; } .li6:after { content: ' '; border: solid transparent; position: absolute; border-width: 15px; border-top-color: #000; border-right-color: #000; top: -1px; right: -1px; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。
标签:linear-gradi CSS3
您可能感兴趣
- html5带放大镜的搜索代码(html5借用repeating-linear-gradient实现一把刻度尺ruler)
- css3填充式进度条动画(CSS3样式linear-gradient的使用实例)
- css中分割线的渐变效果(CSS学习笔记之可重复渐变repeating-linear-gradient)
- vivo首款智能手表来了 也有血氧饱和度监测,一次充电18天续航(vivo首款智能手表来了)
- 你知道 七夕 的真正含义吗(你知道七夕的真正含义吗)
- 七夕的寓意(七夕的寓意)
- 苏志燮赵恩静结婚,韩国四大公共财产变三人,这么快就有替补了(苏志燮赵恩静结婚)
- 《内在美》后,一大波新韩剧来袭,李钟硕朴信惠宋慧乔玄彬回归(一大波新韩剧来袭)
- 给孩子选购保温杯,注意这4个步骤,比颜值更重要(给孩子选购保温杯)
热门推荐
- pandas怎么抽出重复数据(pandas去除重复列的实现方法)
- tomcatcpu配置(Tomcat进程占用CPU过高的解决方法)
- docker容器编排入门教程(简简单单使用Docker部署Confluence)
- dedecms最新手册(在自己的php页面中使用dedecms标签的代码示例)
- mysql join规则(浅谈为什么MySQL不推荐使用子查询和join)
- html5隐藏数字(HTML5去掉输入框type为number时的上下箭头的实现方法)
- vueclass和style绑定(Vue中Class和Style实现v-bind绑定的几种用法)
- python numpy矩阵详解(基于Numpy.convolve使用Python实现滑动平均滤波的思路详解)
- python获取txt文件内容(使用python读取.text文件特定行的数据方法)
- iframe 弹窗(遮罩层 + Iframe实现界面自动显示的示例代码)