How to position element in the correct 3d position with css perspective

喜夏-厌秋 提交于 2019-12-02 05:28:28
Andrei Gheorghiu

perspective needs to be added to the parent, not to the child. The rest are details:

span {
  background: green;
  width: 256px;
  height: 176px;
  position: absolute;
  top: 0;
  left: 0;
  transform: rotateX(1deg) rotateY(-7deg) rotateZ(-1deg) skew(-11.25deg, 1.5deg) translate(233px, 37px);
  opacity: 0.5;
}

div {
  position: relative;
  perspective: 400px;
  width: 1200px;
}

img {
  width: 500px;
  height: auto;
}

body {
  overflow-x: hidden;
}
<div>
  <span></span>
  <img src="https://i.stack.imgur.com/iL2xf.png" />
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!