<div class="container">
  <div class="wrapper">
    <h2>CSS Transform Level 1: tranlate()</h2>
    <div class="box">
      <div class="item old"></div>
    </div>
  </div>

  <div class="wrapper">
    <h2>CSS Transform Level 2: tranlate</h2>
    <div class="box">
      <div class="item new"></div>
    </div>
  </div>
</div>
<footer>
  <p>请使用Firefox 72+浏览器查看Demo效果(^_^)!</p>
</footer>
@import url('https://fonts.googleapis.com/css?family=Gochi+Hand');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


body {
  margin: 0;
  padding: 0;
  background-color: #291642;
  font-family: 'Gochi Hand', sans-serif;
  color: #fff;
  font-size: 130%;
  letter-spacing: 0.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100vw;
  min-height: 100vh;
  
  .container {
    flex: 1;
    display: flex;
    width: 100vw;
    justify-content: center;
    align-items: center;
    padding-top: 20vh;
    padding-bottom: 40vh;
  }
  
  footer {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(#000, .75);
    width: 100vw;
    padding: 20px;
  }
}

.wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 4vh;
}

.box {
  width: 40vh;
  height: 40vh;
  margin: 2vh 6vh;
  border: 1px dashed #f36;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.item {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 40vh;
  height: 40vh;
  transform-origin: center center;
  
  display: flex;
  justify-content: center;
  align-items: center;
  
  background: hsla(343,100%,58%,.3);
  
  &::after {
    content:'';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 100%;
  }
}

.old {
  transform: translate(20vh, 30vh);
}

.new {
  translate: 20vh 30vh;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.