如何复制CSS3动画按钮?

时间:2014-09-02 10:33:14

标签: html css css3 css-animations

我正在尝试从我所在的网站复制CSS3动画按钮。除了实际的动画本身之外,我还有大部分造型工作。

Here is the button.我正在尝试做明星,这是第三部分形成底部的绿色背景。捕获在下面。

enter image description here

HTML:

<button id="BUTTON_1">
    Fav
</button>

CSS:

#BUTTON_1 {
    box-shadow: rgb(17, 158, 77) 0px 5px 0px 0px;
    color: rgb(255, 255, 255);
    cursor: pointer;
    height: 50px;
    letter-spacing: 1px;
    position: relative;
    text-transform: uppercase;
    width: 60px;
    perspective-origin: 30px 25px;
    transform-origin: 30px 25px;
    background: rgb(23, 170, 86) none repeat scroll 0% 0% / auto padding-box border-box;
    border: 0px none rgb(255, 255, 255);
    border-radius: 7px 7px 7px 7px;
    font: normal normal bold 0px/normal Lato, Calibri, Arial, sans-serif;
    margin: 15px 30px;
    outline: rgb(255, 255, 255) none 0px;
    padding: 25px 30px;
    transition: all 0.3s ease 0s;
}

 #BUTTON_1:after {
    color: rgb(255, 228, 77);
    cursor: pointer;
    display: block;
    height: 50px;
    left: 0px;
    letter-spacing: 1px;
    opacity: 0;
    position: absolute;
    speak: none;
    top: 0px;
    visibility: hidden;
    width: 60px;
    z-index: 1;
    align-items: stretch;
    align-self: flex-start;
    perspective-origin: 30px 25px;
    transform: matrix(4, 0, 0, 4, 0, 0);
    transform-origin: 30px 25px;
    content:'';
    background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;
    border: 0px none rgb(255, 228, 77);
    font: normal normal normal 26px/54px icomoon;
    margin: 0px;
    outline: rgb(255, 228, 77) none 0px;
    padding: 0px;
    transition: none 0s ease 0s;
}

 #BUTTON_1:before {
    color: rgb(255, 255, 255);
    cursor: pointer;
    display: block;
    height: 50px;
    left: 0px;
    letter-spacing: 1px;
    position: absolute;
    speak: none;
    top: 0px;
    width: 60px;
    backface-visibility: hidden;
    align-items: stretch;
    align-self: flex-start;
    perspective-origin: 30px 25px;
    transform-origin: 30px 25px;
    content:'';
    background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;
    border: 0px none rgb(255, 255, 255);
    font: normal normal normal 26px/54px icomoon;
    margin: 0px;
    outline: rgb(255, 255, 255) none 0px;
    padding: 0px;
}

 .#BUTTON_1:before {
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #fff;
}

.#BUTTON_1:after {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 1;
    font-size: 26px;
    line-height: 54px;
    color: #ffe44d;
    visibility: hidden;
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #ffe44d;
    -webkit-transform: scale(4);
    -moz-transform: scale(4);
    -ms-transform: scale(4);
    transform: scale(4);
    opacity: 0;
    -webkit-transition: none;
    -moz-transition: none;
    transition: none;
}

.#BUTTON_1.btn-activated:after {
    visibility: visible;
    -webkit-animation: dropDown 0.3s forwards;
    -moz-animation: dropDown 0.3s forwards;
    animation: dropDown 0.3s forwards;
}

@-webkit-keyframes dropDown {
    to {
        opacity: 1;
        -webkit-transform: scale(1);
    }
}

@-moz-keyframes dropDown {
    to {
        opacity: 1;
        -moz-transform: scale(1);
    }
}

@keyframes dropDown {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

Demo of my attempt

不用担心字体(正如你所看到的,我的例子没有安装字体),就在动画处理按钮之后。我已经尝试找到附加的所有关键帧和样式,但我似乎仍然无法使其正常工作。

我错过了什么让这个工作?

1 个答案:

答案 0 :(得分:1)

class="btn-activated" is missing in <button id="BUTTON_1" class="btn-activated">

删除点,

.#BUTTON_1.btn-activated:after {
( In all cases .#BUTTON_1)

#BUTTON_1.btn-activated:after {

的jQuery

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$('document').ready(function(){
    $('#BUTTON_1').click(function(){
     $(this).addClass('btn-activated');
    });     
});
</script>

在你的小提琴中选择框架中的jquery&amp;扩展

并在javascipt酒吧

粘贴

$('document').ready(function(){
    $('#BUTTON_1').click(function(){
     $(this).addClass('btn-activated');
    });     
});

<button id="BUTTON_1" class="btn-activated">

<button id="BUTTON_1">