If you change the .page
property of the transform
, that is, change deg
, then the block rotates around its edge, is it possible to make it rotate relative to the center?
* { margin: 0; padding: 0; } .container { transform-style: preserve-3d; } .page { transform-origin: 50% 50%; transform-style: preserve-3d; backface-visibility: hidden; transform-origin: center center; margin: 100px; margin-left: 400px; position: relative; transform: rotateX(20deg); perspective: 800px; } .slide { position: absolute; width: 300px; height: 300px; display: flex; align-items: center; justify-content: center; font-size: 40px; color: #c8d6e5; } .slide:nth-child(1) { background-color: #1dd1a1; transform: translateZ(150px); } .slide:nth-child(2) { background-color: #feca57; transform: rotateX(90deg) translateZ(150px); } .slide:nth-child(3) { background-color: #ff6b6b; transform: rotateX(-90deg) translateZ(150px); } .slide:nth-child(4) { background-color: #48dbfb; transform: rotateY(180deg) translateZ(150px); }
<div class="container"> <div class="page"> <div class="slide"> We are creative </div> <div class="slide"> We are cool </div> <div class="slide"> We are mazing </div> <div class="slide"> We are super </div> </div> </div>