CSS3 translate out of screen

后端 未结 8 1682
南旧
南旧 2021-02-07 07:48

For a number of projects now I have had elements on the page which I want to translate out of the screen area (have them fly out of the document). In proper code this should be

8条回答
  •  攒了一身酷
    2021-02-07 08:08

    Use calc method (http://jsfiddle.net/ATcpw/2/):

    .block{
        position:absolute;
        top: -webkit-calc(100% - 110px);
        right:10px;
        left:10px;
        height:100px;
        background:gray;
        -webkit-transition: all 2s;
        /*this adds GPU acceleration*/
        transform: translate3d(0,0,0); 
        -webkit-transform: translate3d(0,0,0);
    }
    .block.hide{
        top: -100px;
    }
    

    Since you are using -webkit prefix I used it as well. calc is supported by majority of browsers: http://caniuse.com/#search=calc

提交回复
热议问题