简体   繁体   中英

Rotate an element around another element - css

I am working with CSS, and want to do an effect where an object is moving around another object in an ellipse. I am not using a canvas, and this is my html:

<div>/*Content intended for ellipse movement*/</div>
<div>/*Element to ellipse around*/</div>

I do not have any css at this time How do I do this? Thanks for your help!

Are you trying to do something like this?

 body { padding: 50px; } div { position: absolute; width: 100px; height: 100px; background: #9f9; } .high { background-color: #99f; z-index: 1; -webkit-animation: spin 4s linear infinite; -moz-animation: spin 4s linear infinite; animation: spin 4s linear infinite; } @-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
 <div class="low"></div> <div class="high"></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM