html - CSS transform-origin + stacked divs -


i attempting rotate/spin-in-place stacked divs, 'transform-origin' property seems ignored when using absolute divs.

attached example, divs stacked using stack class. using svg better solution?

.circle {    height: 250px;    width: 250px;    border-radius: 50%;    border: 50px solid white;    margin: auto;  }    body {    background: black;    overflow: hidden;  }    .circle_one {    animation: rotatey 3s infinite linear;  }    .circle_two {    animation: rotatex 2s infinite linear;  }    .spinme {    animation: spinme 2s infinite linear;    transform-origin: 50% 50%;  }    .stack {    position: absolute;    top: 0;    left: 0;  }    @-webkit-keyframes rotatey {    {      transform: rotatey(360deg);    }  }    @-webkit-keyframes rotatex {    {      transform: rotatex(360deg);    }  }    @-webkit-keyframes spinme {    {      transform: rotate(360deg);    }  }
<div class="spinme">  <div class="circle circle_one stack"></div>  <div class="circle circle_two stack"></div>    </div>

the problem spinme element has 100% width , 0 height due absolutely positioned children. if give spinme defined width , height equal .circle works correctly.

.circle {    height: 250px;    width: 250px;    border-radius: 50%;    border: 50px solid white;    margin: auto;  }    body {    background: black;    overflow: hidden;  }    .circle_one {    animation: rotatey 3s infinite linear;  }    .circle_two {    animation: rotatex 2s infinite linear;  }    .spinme {    animation: spinme 2s infinite linear;    transform-origin: 50% 50%;    width: 350px;    height: 350px;  }    .stack {    position: absolute;    top: 0;    left: 0;  }    @-webkit-keyframes rotatey {    {      transform: rotatey(360deg);    }  }    @-webkit-keyframes rotatex {    {      transform: rotatex(360deg);    }  }    @-webkit-keyframes spinme {    {      transform: rotate(360deg);    }  }
<div class="spinme">  <div class="circle circle_one stack"></div>  <div class="circle circle_two stack"></div>    </div>


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -