使用css3的currentColor属性快速实现换肤功能

2024-11-07 16:09:10

1、首先我们在父元素里面定义一个color属性值

使用css3的currentColor属性快速实现换肤功能

2、然后在子元素添加其他的颜色值;使用currentColor就能继承了

使用css3的currentColor属性快速实现换肤功能

3、最后显示如下效果

使用css3的currentColor属性快速实现换肤功能

4、和伪类一起快速实现鼠标经过改变状态需求

使用css3的currentColor属性快速实现换肤功能

5、最终显示效果

使用css3的currentColor属性快速实现换肤功能

6、最后说下兼容性问题,大部分主流浏览器都支持的,手机端更是好用,请看下图

使用css3的currentColor属性快速实现换肤功能
猜你喜欢