1、伪类需要position定位,相对的button也需要定位一下
2、设置一下z-index属性,一般button设置为1, button::after或者button:before设置为-1即可
3、transition实现动画效果,如果需要transform旋转一下
代码如下:
button:hover:after {width: 100%;} button:hover {color: #000;} button:after {content: '';background-color: #fff;transition: all .5s;width: 0%;position: absolute;top: 3px;left: 0px;height: 34px;z-index: -1;} button {width: 100px;height: 40px;border: 0px;color: white;background-color: red;font-size: 16px;position: relative;z-index: 1;cursor: pointer;font-family: 'Microsoft YaHei';} 保存
查看更多关于基础理解2:CSS3按钮动画_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did112537