css
Posted gyz418
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css相关的知识,希望对你有一定的参考价值。
按钮点击效果
1缩小放大
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <style> #btn{ width: 200px; height: 80px; line-height: 80px; background: #cccccc; text-align: center; font-size: 30px; } #btn.active{ animation: show 1s; } @keyframes show { 0%{ transform: scale(.9); } 50%{ transform: scale(1); } } </style> <div id="btn">btn</div> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> <script> $("#btn").click(function () { $(this).addClass(‘active‘).one(‘animationend‘,function () { $(this).removeClass(‘active‘) }) }) </script> </body> </html>
2.波纹效果 https://mladenplavsic.github.io/css-ripple-effect/#
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .ripple { position: relative; /*//隐藏溢出的径向渐变背景*/ overflow: hidden; } .ripple:after { content: ""; display: block; position: absolute; width: 100%; height: 100%; top: 0; left: 0; pointer-events: none; /*//设置径向渐变*/ background-image: radial-gradient(circle, #666 10%, transparent 10.01%); background-repeat: no-repeat; background-position: 50%; transform: scale(10, 10); opacity: 0; transition: transform .3s, opacity .5s; } .ripple:active:after { transform: scale(0, 0); opacity: .3; /*!/设置初始状态*/ transition: 0s; } .btn{ width:100px; height: 50px; line-height: 50px; text-align: center; background: #cccccc; } </style> </head> <body> <div class="ripple btn">btn</div> </body> </html>
以上是关于css的主要内容,如果未能解决你的问题,请参考以下文章