Is there a way to avoid repeating the elements in my code and only change the "rotate" value that interests me?
I heard about using "Counter-increment" online but I'm not sure how to implement it in my code.
I am using vuejs to prevent repeating 30 divs.
<div class="wrapper">
<div class="circle-container">
<div class="circle" v-for="i in 30"></div>
</div>
</div>
.wrapper {
display: flex;
width: 100%;
height: 500px;
margin: 30px auto;
}
.circle-container {
margin: 60px;
position: relative;
width: 100%;
height: 100%;
}
.circle {
position: absolute;
top: 50%;
left: 50%;
width: 60px;
height: 60px;
border-radius: 50%;
opacity: 0.7;
}
.circle:nth-child(1) {
-webkit-transform: rotate(0deg) translateX(500%);
-moz-transform: rotate(0deg) translateX(500%);
-ms-transform: rotate(0deg) translateX(500%);
-o-transform: rotate(0deg) translateX(500%);
transform: rotate(0deg) translateX(500%);
background: #42A5F5;
}
.circle:nth-child(2) {
-webkit-transform: rotate(12deg) translateX(500%);
-moz-transform: rotate(12deg) translateX(500%);
-ms-transform: rotate(12deg) translateX(500%);
-o-transform: rotate(12deg) translateX(500%);
transform: rotate(12deg) translateX(500%);
background: #ffe63d;
}
.circle:nth-child(3) {
-webkit-transform: rotate(24deg) translateX(500%);
-moz-transform: rotate(24deg) translateX(500%);
-ms-transform: rotate(24deg) translateX(500%);
-o-transform: rotate(24deg) translateX(500%);
transform: rotate(24deg) translateX(500%);
background: #ffe63d;
}
Repeat this pattern 30 times, increasing by 12 degrees each time.