How can I rotate two divs to form an X when I click the container div?

扶醉桌前 提交于 2021-02-05 08:35:18

问题


Here's what I have now: code

this is the html

<div id="box">
    <div id="line1" class="line"></div>
    <div id="line2" class="line"></div>
    <div id="line3" class="line"></div>
</div>

I would like to use jQuery to rotate line1 and line3 to form an X and make line2 disappear when you click the container div (#box). I like the idea of jQuery because of Animation, but any other ideas are welcome.


回答1:


You can do something like This

.rotateL{
    transform:rotate(45deg) translateX(10px);
    -webkit-transform:rotate(45deg) translateX(10px);
    transform-origin:30%;
    -webkit-transform-origin:30%;
}

.rotateR{
    transform:rotate(-45deg) translateY(10px);
    -webkit-transform:rotate(-45deg) translateY(10px);
    transform-origin:22%;
    -webkit-transform-origin:22%;
}


来源:https://stackoverflow.com/questions/23996045/how-can-i-rotate-two-divs-to-form-an-x-when-i-click-the-container-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!