zoukankan      html  css  js  c++  java
  • 按钮的有趣特效

    1.上下滑动特效

    代码结构:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
    .btns {
    200px;
    height: 30px;
    margin: 30px auto;
    background-color: #0000FF;
    display: block;
    outline: none;
    border: none;
    position: relative;
    z-index: 1;
    color: #fff;
    }

    .btns:before {
    content: "";
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    transform-origin: center bottom;
    transform: scaleY(0);
    background-color: red;
    transition: transform 0.4s ease-in-out;
    }

    .btns:hover {
    cursor: pointer;
    }

    .btns:hover:before {
    transform: scaleY(1);
    transform-origin: center top;
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">上下滑动</button>
    </body>
    </html>

    2.左右震动特效

    代码结构:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
    .btns {
    margin: 50px auto;
    display: block;
    position: relative;
    z-index: 1;
    background-color: #0000FF;
    outline: none;
    border: none;
    300px;
    height: 40px;
    color: #fff;
    }

    .btns:hover {
    cursor: pointer;
    animation: dong 0.4s;
    }

    @keyframes dong {

    0%,
    100% {
    transform: scale(1, 1);
    }

    25%,
    75% {
    transform: scale(0.95, 1.1);
    }

    50% {
    transform: scale(1.1, 0.95);
    }
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">左右震动动效</button>
    </body>
    </html>

    3.左右放大动效

    代码结构

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style>
    .btns {
    margin: 50px auto;
    display: block;
    position: relative;
    z-index: 1;
    background-color: #0000FF;
    outline: none;
    border: none;
    300px;
    height: 40px;
    color: #fff;
    }

    .btns:hover {
    cursor: pointer;

    }
    .btns:before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    border: 4px solid #0000FF;
    transform: scale(1);
    transform-origin: center;
    }
    .btns:hover:before {
    transition: all 0.4s ease-out;
    border: 1px solid #0000FF;
    transform: scale(1.1);
    opacity: 0;
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">左右放大动效</button>
    </body>
    </html>

    4.倾斜的闪光特效

    代码特效:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>倾斜的闪光特效</title>
    <style type="text/css">
    .btns {
    outline: none;
    border: none;
    z-index: 1;
    position: relative;
    color: white;
    background: #262626;
    padding: 0.5em 1em;
    overflow: hidden;
    /* --shine- 1.25em; */
    margin:50px auto;
    100px;
    display:block;
    }

    .btns:after {
    content: "";
    z-index: -1;
    position: absolute;
    background: red;
    top: -100%;
    height:20px;
    left: 0%;
    bottom: -50%;
    100px;
    transform: translate3d(-200%, 0, 0) rotate(125deg);
    /* */
    }

    .btns:hover {
    cursor: pointer;
    }

    .btns:hover:after {
    transition: transform 0.8s ease-in-out;
    transform: translate3d(100%, 236%, 0) rotate(125deg);
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">闪光特效</button>
    </body>
    </html>

    5.气泡特效

    代码结构:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
    .btns {
    outline: none;
    border: none;
    cursor: pointer;
    color: white;
    position: relative;
    100px;
    display: block;
    margin: 50px auto;
    padding: 0.5em 1em;
    background-color: #40a9ff;
    z-index: 1;
    overflow: hidden;
    }

    .btns:before {
    z-index: -1;
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    1em;
    height: 1em;
    border-radius: 50%;
    background-color:red;
    transform-origin: center;
    transform: translate3d(-50%, -50%, 0) scale(0, 0);
    transition: transform 0.4s ease-in-out;
    }.btns:hover:before {

    transform: translate3d(-50%, -50%, 0) scale(10,10);
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">气泡特效</button>
    <!-- 首先,还是去掉 button 元素的默认样式-->
    <!-- 然后:由于 button 的伪元素层级是覆盖 button 的,设置 z-index 属性,防止伪元素遮盖显示。只想要背景色的遮盖,字体不需要遮盖。 -->
    <!-- 最后:伪元素的变化效果。特效是从中心向四周蔓延,让其居中。大小变化,还是利用scale属性。圆形,所以将border-radius设置为 50%即可。 -->
    </body>
    </html>

    6.左右滑动特效

    代码结构:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>左右滑动特效</title>
    <style type="text/css">
    .btns {
    outline: none;
    border: none;
    cursor: pointer;
    color: white;
    position: relative;
    100px;
    display: block;
    margin: 50px auto;
    padding: 0.5em 1em;
    background-color: #40a9ff;
    z-index: 1;
    overflow: hidden;
    }

    button::before {
    z-index: -1;
    content: "";
    position: absolute;
    1em;
    height: 1em;
    border-radius: 50%;
    background-color: #9254de;
    top: 0;
    left: 0;
    transform-origin: center;
    transform: scale3d(0, 0, 0);
    transition: transform 0.45s ease-in-out;
    }
    button:hover::before {
    transform: scale3d(20,20, 20);
    }
    </style>
    </head>
    <body>
    <button type="button" class="btns">气泡特效</button>

    </body>
    </html>

  • 相关阅读:
    P3373 线段树模板
    由AC自动机引发的灵感
    瞎子摸象序
    Outer Join的where条件
    将 转移单 自动发货
    获取某个结点的所有层
    瞎子摸象库存篇
    js修改select列表选项中的值
    JS仿flash动态切换(横向,带分页器控制,自动正反向循环轮播)
    js操作select下拉列表的一些通用代码
  • 原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11295742.html
Copyright © 2011-2022 走看看