WebKit: Is there any css trick to bring elements t

2019-08-07 09:35发布

From the picture, I use rotate3d() to the red rectangle so half of it is in front of black rectangle and the other is behind.

enter image description here

I want black rectangle to be front of red rectangle so I have to use translateZ() so it become

enter image description here

The problem is that I want black rectangle to be front without scaling it. I want black rectangle to still be the same size. Is there any trick? I tried z-index but it didn't work. I guess it because I use rotate3d().

Thanks in advance.

1条回答
时光不老,我们不散
2楼-- · 2019-08-07 10:36

I do not have access to Safari at present to test it in, so I leave that to you (let me know if it works), but I believe the following should work.

Since browser interpretation of -webkit-perspective seems to be the problem as I noted in my answer to this question, remove it from #container and replace it with -webkit-transform: perspective(500) and then add the same thing (-webkit-transform: perspective(500)) to both #parent and #parent2 which is what I have done in this fiddle.

The issue seems to be that Safari does not apply a perspective to the #container when using -webkit-perspective whereas Chrome does. It seems to be a matter of interpretation of the spec, as I discussed in answering the other question.

查看更多
登录 后发表回答