Swinging world

In this example below you will see how to do a Swinging world with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by Dreamdealer, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Dreamdealer ©
  • HTML
  • CSS
  • JavaScript
    <span><div>Hello World!</div></span>

/*Downloaded from https://www.codeseek.co/Dreamdealer/swinging-world-CDbAw */
    body {
  background: lightblue;
  padding-top: 30px;
}
div {
  background: #fff url(https://www.telescopes-astronomy.com.au/world_map_wallpaper2.jpg);
  background-size: cover;
  font-size: 50px;
  width: 400px;
  padding: 90px 0px;
  text-align: center;
  border-radius: 5px;
  box-shadow: 
     0px 1px 3px rgba(0,0,0,0.2),
     0 0 1px 5px #FFF inset;
  text-shadow: 
    1px 1px 0 #FFF, 
    -1px -1px 0 #FFF,
    1px -1px 0 #FFF,
    -1px 1px 0 #FFF;
  position: absolute;
  border: 1px solid #AAA;
  transform: translate(-100px,-20px) rotate(-45deg);
}
span {
  margin: 0 auto;
  display: block;
  position: relative;
  width: 30px;
  height: 30px;
  background: transparent;
  border-radius: 3px;
  border: 1px solid black;
  animation: infinite swing 3s ease-in-out;
  transform-origin: 0 0;
}

@keyframes swing {
  0%{ transform: rotate(35deg); }
  50%{ transform: rotate(55deg); }
  100%{ transform: rotate(35deg); }
}


/*Downloaded from https://www.codeseek.co/Dreamdealer/swinging-world-CDbAw */
    /*

I could not use a :after pseudo class to add the little triangle, because the z-index gets screwed in Chrome when adding a transformation. Renderbug?

*/

Comments