Translate X and Y percentage values based on elements height and width?

前端 未结 9 1738
情歌与酒
情歌与酒 2020-12-08 03:29

Translating an elements Y axis 50% will move it down 50% of its own height, not 50% of the parents height as I would expect. How do I tell a translating element to base it\'

9条回答
  •  無奈伤痛
    2020-12-08 04:12

    You can also use one extra block and use the transition for it except the child node

    HTML code :

    ​​​​​​​​​​​​​

    css should be something like this

    #parent {
        position: relative;
        width: 200px;
        height: 200px;
        background: #ff0;
    }
    #childrenWrapper{
        width: 100%;
        height: 100%;
    }
    #children {
        width: 10%;
        height: 10%;
        background: #f00;
    }
    

提交回复
热议问题