.page { width: 600px; height: 600px; border: 1px solid gray; position: relative; } .page div[class*="mypro"] { width: 300px; height: 350px; border: 0px solid gray; position: absolute; left: 150px; top: 100px; } .mypro1 { animation-name: demo1; animation-duration: 3s; animation-iteration-count: infinite; animation-timing-function: linear; animation-direction: normal; } @keyframes demo1 { 0% { transform: rotate(0deg); } 50% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }