Onclick CSS button effect

前端 未结 4 2097
梦毁少年i
梦毁少年i 2021-02-05 12:56

I\'m creating a CSS button and I\'m trying to make an onclick effect: when the user clicks on the button it would push down the button text by 1px. My problem here is that it\'s

4条回答
  •  粉色の甜心
    2021-02-05 13:58

    This is a press down button example I've made:

    ...

    the CSS file:

    .thumbnail {
        width: 128px;
        height: 128px;
    }
    
    .image {
        width: 100%;
        height: 100%;    
    }
    
    .image img {
        -webkit-transition: all .25s ease; /* Safari and Chrome */
        -moz-transition: all .25s ease; /* Firefox */
        -ms-transition: all .25s ease; /* IE 9 */
        -o-transition: all .25s ease; /* Opera */
        transition: all .25s ease;
        max-width: 100%;
        max-height: 100%;
    }
    
    .image:hover img {
        -webkit-transform:scale(1.05); /* Safari and Chrome */
        -moz-transform:scale(1.05); /* Firefox */
        -ms-transform:scale(1.05); /* IE 9 */
        -o-transform:scale(1.05); /* Opera */
         transform:scale(1.05);
    }
    
    .image:active img {
        -webkit-transform:scale(.95); /* Safari and Chrome */
        -moz-transform:scale(.95); /* Firefox */
        -ms-transform:scale(.95); /* IE 9 */
        -o-transform:scale(.95); /* Opera */
         transform:scale(.95);
    }
    

    Enjoy it!

提交回复
热议问题