6种css按钮动画

先看效果

image

这几种效果还可以做成鼠标hover效果

第一种

 <div class="btn1 btn">流光</div>
.btn1 {

  width: 100px;

  height: 40px;

  border-radius: 10px;

  background-color: #00b16a;

  overflow: hidden;

  position: relative;

  margin: 10px auto;

  display: flex;

  align-items: center;

  justify-content: center;

}

.btn1::before {

  content: "";

  display: block;

  width: 25px;

  height: 50px;

  background: rgba(255, 255, 255, 0.3);

  transform: skewX(-25deg);

  position: absolute;

  left: -35px;

  animation: guang infinite 0.8s ease-in;

}

@keyframes guang {

  50% {

    left: -45px;

  }

  100% {

    left: 110px;

  }

}

第二种

<div class="btn2-wrapper">
            <div class="btn2 btn">
                边框
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
.btn2-wrapper {
  overflow: hidden;
  margin: 10px auto;
  width: 106px;
  height: 46px;
}

.btn2 {
  width: 100px;
  height: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #186d4b;
  background-color: #00b16a;
}

.btn2 span:nth-child(1) {
  width: 100px;
  height: 3px;
  border-radius: 0 10px 10px 0;
  position: absolute;
  top: -3px;
  left: -103px;
  animation: bordertop 2s linear infinite;
  background: linear-gradient(to right, #186d4b, #fff);
}

.btn2 span:nth-child(2) {
  width: 3px;
  height: 40px;
  border-radius: 0 0 10px 10px;
  position: absolute;
  top: -43px;
  right: -3px;
  animation: borderright 2s linear 1s infinite;
  background: linear-gradient(to bottom, #186d4b, #fff);
}

.btn2 span:nth-child(3) {
  width: 100px;
  height: 3px;
  border-radius: 10px 0 0 10px;
  position: absolute;
  top: 40px;
  right: -103px;
  animation: borderbottom 2s linear 2s infinite;
  background: linear-gradient(to left, #186d4b, #fff);
}

.btn2 span:nth-child(4) {
  width: 3px;
  height: 40px;
  border-radius: 10px 10px 0 0;
  position: absolute;
  top: 43px;
  left: -3px;
  animation: borderleft 2s linear 3s infinite;
  background: linear-gradient(to top, #186d4b, #fff);
}

@keyframes bordertop {
  100% {
    left: 100px;
  }
}

@keyframes borderright {
  100% {
    top: 40px;
  }
}

@keyframes borderbottom {
  100% {
    right: 100px;
  }
}

@keyframes borderleft {
  100% {
    top: -43px;
  }
}

第三种

<div class="btn3">|</div>
.btn3 {
  margin: 10px auto;
  width: 60px;
  height: 60px;
  line-height: 2.6;
  font-size: 24px;
  text-align: center;
  color: #e1dada;
  text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.2);
  border-radius: 100px;
  text-decoration: none;
  background-image: -webkit-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0%, #f4f4f4),
    color-stop(100%, #e3e3e3)
  );
  background-image: -moz-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0%, #f4f4f4),
    color-stop(100%, #e3e3e3)
  );
  box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.25), 10px 10px 15px #e3e3e3,
    -10px 10px 15px #e3e3e3, -15px -15px 15px rgba(255, 255, 255, 0.4),
    15px -15px 15px rgba(255, 255, 255, 0.4), inset 0px 2px 0px white;
  -webkit-transition: box-shadow 0.3s ease-in-out,
    background-image 0.3s ease-in-out, text-shadow 0.5s linear,
    color 0.5s linear;
  -moz-transition: box-shadow 0.3s ease-in-out,
    background-image 0.3s ease-in-out, text-shadow 0.5s linear,
    color 0.5s linear;
}

.btn3.active {
  color: #00d0b0;
  text-shadow: 0px 0px 1px #37ffb1;
  background-image: -webkit-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0%, #e3e3e3),
    color-stop(100%, #f4f4f4)
  );
  background-image: -moz-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0%, #e3e3e3),
    color-stop(100%, #f4f4f4)
  );
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.15),
    10px 10px 15px rgba(255, 255, 255, 0.4),
    -10px 10px 15px rgba(255, 255, 255, 0.4), -10px -10px 15px #e3e3e3,
    10px -10px 15px #e3e3e3, inset 0px -3px 0px rgba(255, 255, 255, 0.4),
    inset 0px 3px 3px rgba(0, 0, 0, 0.04);
}

第四种

<div class="btn4">btn4</div>
.btn4 {
  width: 100px;
  height: 40px;
  border-radius: 30px;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: btn4Ani 2s linear infinite;
}
@keyframes btn4Ani {
  0% {
    width: 100px;
    height: 40px;
  }
  30% {
    width: 140px;
    height: 56px;
    transform: rotate(0deg);
  }
  40% {
    width: 140px;
    height: 56px;
    transform: rotate(-5deg);
  }
  50% {
    width: 140px;
    height: 56px;
    transform: rotate(5deg);
  }
  60% {
    width: 140px;
    height: 56px;
    transform: rotate(-5deg);
  }
  70% {
    width: 140px;
    height: 56px;
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(0deg);
    width: 100px;
    height: 40px;
  }
}

第五种

<div class="btn5">btn5</div>
.btn5 {
  width: 100px;
  height: 40px;
  border-radius: 30px;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.btn5::before {
  content: "";
  display: block;
  width: 100px;
  height: 40px;
  border-radius: 30px;
  border: 3px solid rgba(255, 255, 255, 1);
  position: absolute;
  top: -3px;
  left: -3px;
  animation: btn5AniBefore 2s ease-in-out infinite;
}
.btn5::after {
  content: "";
  display: block;
  width: 100px;
  height: 40px;
  border-radius: 30px;
  border: 3px solid rgba(255, 255, 255, 1);
  position: absolute;
  top: -3px;
  left: -3px;
  animation: btn5AniAfter 2s ease-in-out infinite;
}
@keyframes btn5AniBefore {
  0% {
    top: -3px;
    left: -3px;
    border: 3px solid rgba(255, 255, 255, 1);
  }
  100% {
    top: -12px;
    left: -12px;
    border: 12px solid rgba(255, 255, 255, 0.5);
  }
}
@keyframes btn5AniAfter {
  0% {
    top: -3px;
    left: -3px;
    border: 3px solid rgba(255, 255, 255, 1);
  }
  100% {
    border-radius: 60px;
    top: -30px;
    left: -30px;
    border: 30px solid rgba(255, 255, 255, 0.3);
  }
}

第六种

<div class="btn6">
            btn6
            <span>YOYO!</span>
            <span>YOYO!</span>
            <span>YOYO!</span>
            <span>YOYO!</span>
            <span>YOYO!</span>
        </div>
.btn6 {
  width: 100px;
  height: 40px;
  border-radius: 30px;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.btn6 span {
  position: absolute;
  font-family: "Margarine";
  animation: btn6Ani .8s infinite;
}
.btn6 span:nth-child(1) {
  top: -40px;
  left: -10px;
  transform: rotate(15deg);
  animation-duration: 1s;
}
.btn6 span:nth-child(2) {
    top: -38px;
    left: 60px;
    transform: rotate(5deg);
    animation-duration: .3s;
}
.btn6 span:nth-child(2) {
    top: -58px;
    left: 60px;
    transform: rotate(0deg);
    animation-duration: .5s;
}
.btn6 span:nth-child(3) {
    top: -18px;
    left: 110px;
    transform: rotate(10deg);
    animation-duration: .7s;
}
.btn6 span:nth-child(4) {
    top: 50px;
    left: 80px;
    transform: rotate(-40deg);
    animation-duration: 1.2s;
}
.btn6 span:nth-child(5) {
    top: 60px;
    left:10px;
    transform: rotate(10deg);
    animation-duration: .8s;
}
@keyframes btn6Ani {
    0%{
        color: #fff;
    }
    100%{
        color: transparent;
    }
}

多多交流,欢迎指正!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,277评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,689评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,624评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,356评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,402评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,292评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,135评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,992评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,429评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,636评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,785评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,492评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,092评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,723评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,858评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,891评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,713评论 2 354