CSS Rotate Animation (Nested Element)

Posted on : 24th October 2022 | Author : @ByDev24
						<div class="code-container">
	<div class="root-box">
		<div class="root-circle">
			<div class="root-box-2">
				<div class="root-circle child2">
					<img src="https://code.bydev24.com/uploads/code-snippts/0ce5842f065de7c9c7bb632d3937765a.png" class="smile-face">
				</div>
			</div>
		</div>
	</div>
</div>
					
						.code-container {
    box-shadow: 0px 0px 5px 5px #00000008;
    max-width: 100%;
    width: 450px;
    border-radius: 10px;
    position: relative;
    padding: 80px 0px;
    transition: 0.6s;
}
.root-box {
    width: 250px;
    height: 250px;
    margin: 0 auto;
    animation: r-to-l 5s infinite linear;
    display: flex;
    align-items: center;
    background: #F47122;
    background: -webkit-linear-gradient(top left, #F47122, #B12467);
    background: -moz-linear-gradient(top left, #F47122, #B12467);
    background: linear-gradient(to bottom right, #F47122, #B12467);
    border-radius: 20px;
}
.root-circle {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    border-radius: 50%;
    animation: l-to-r 3s infinite linear;
    background: #C85D45;
    background: -webkit-linear-gradient(top left, #C85D45, #E5D455);
    background: -moz-linear-gradient(top left, #C85D45, #E5D455);
    background: linear-gradient(to bottom right, #C85D45, #E5D455);
}
.root-box-2 {
    width: 100px;
    height: 100px;
    margin: 0 auto;
    animation: l-to-r 5s infinite linear;
    background: #278D20;
    background: -webkit-linear-gradient(top left, #278D20, #26ECC1);
    background: -moz-linear-gradient(top left, #278D20, #26ECC1);
    background: linear-gradient(to bottom right, #278D20, #26ECC1);
    display: flex;
    align-items: center;
    border-radius: 20px;
}
.root-circle.child2 {
    width: 80px;
    height: 80px;
    background: #D0B655;
    background: -webkit-linear-gradient(top left, #D0B655, #68311C);
    background: -moz-linear-gradient(top left, #D0B655, #68311C);
    background: linear-gradient(to bottom right, #D0B655, #68311C);
    animation: r-to-l 5s infinite linear;
    display: flex;
    align-items: center;
    justify-content: center;
}
.smile-face {
    width: 20px;
    animation: zoom 10s infinite linear;
}
@keyframes r-to-l{
    from{transform:rotate(0deg)}
    to{transform:rotate(360deg)}
}
@keyframes l-to-r{
    from{transform:rotate(0deg)}
    to{transform:rotate(-360deg)}
}
@keyframes zoom{
    0%{transform:scale(1)}
    50%{transform:scale(5)}
    100%{transform:scale(1)}
}
					
						console.log('Hello')
					

Output

More Snipps