使用firefox打破3D变换z-index,保留-3d未保存

时间:2016-12-19 11:01:23

标签: html css css3 firefox transform

Firefox中的3D变换似乎与z-index存在问题。在我看来,渲染是“忽略”3D Z位置,并简单地使用来自DOM的z-index。有趣的是,当可见部分变小时,只有轮子的一部分可见,z-index突然正确,尽管其他工件开始出现。

自2011年以来,在Firefox中有这样的交叉错误演示,但是我的圈子没有相交 - 所以我希望它在某种程度上是可能的。 http://jsfiddle.net/yNfQX/21/

Firefox Bugtracker:https://bugzilla.mozilla.org/show_bug.cgi?id=689498

.perspective {
  width: 400px;
  height: 400px;
  position: relative;
  perspective: 3000px;
  display: block;
}
.dcw {
  width: 100%;
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
}
.dc {
  top: calc(50% - 44px);
  left: calc(50% - 44px);
  margin: auto;
  border-radius: 50%;
  position: absolute;
  cursor: pointer;
  transform-style: preserve-3d;
  width: 88px;
  height: 88px;
  border: 1px solid black;
}
<div class="perspective">
  <div class="dcw">
    <div class="dc" style="background-color: rgba(255,0,0,1);transform:    rotateZ( 0deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(251,4,4,1);transform:    rotateZ( 10deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(248,7,7,1);transform:    rotateZ( 20deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(244,11,11,1);transform:    rotateZ( 30deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(241,14,14,1);transform:    rotateZ( 40deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(237,18,18,1);transform:    rotateZ( 50deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(234,21,21,1);transform:    rotateZ( 60deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(230,25,25,1);transform:    rotateZ( 70deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(227,28,28,1);transform:    rotateZ( 80deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(223,32,32,1);transform:    rotateZ( 90deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(219,36,36,1);transform:    rotateZ( 100deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(216,39,39,1);transform:    rotateZ( 110deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(212,43,43,1);transform:    rotateZ( 120deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(209,46,46,1);transform:    rotateZ( 130deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(205,50,50,1);transform:    rotateZ( 140deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(202,53,53,1);transform:    rotateZ( 150deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(198,57,57,1);transform:    rotateZ( 160deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(195,60,60,1);transform:    rotateZ( 170deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(191,64,64,1);transform:    rotateZ( 180deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(187,68,68,1);transform:    rotateZ( 190deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(184,71,71,1);transform:    rotateZ( 200deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(180,75,75,1);transform:    rotateZ( 210deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(177,78,78,1);transform:    rotateZ( 220deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(173,82,82,1);transform:    rotateZ( 230deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(170,85,85,1);transform:    rotateZ( 240deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(166,89,89,1);transform:    rotateZ( 250deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(163,92,92,1);transform:    rotateZ( 260deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(159,96,96,1);transform:    rotateZ( 270deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(155,100,100,1);transform:    rotateZ( 280deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(152,103,103,1);transform:    rotateZ( 290deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(148,107,107,1);transform:    rotateZ( 300deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(145,110,110,1);transform:    rotateZ( 310deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(141,114,114,1);transform:    rotateZ( 320deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(138,117,117,1);transform:    rotateZ( 330deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(134,121,121,1);transform:    rotateZ( 340deg ) translateX(125px) rotateX( -60deg ); "></div>
    <div class="dc" style="background-color: rgba(131,124,124,1);transform:    rotateZ( 350deg ) translateX(125px) rotateX( -60deg ); "></div>
  </div>
</div>

JSFiddle: https://jsfiddle.net/gvquf0g6/

它应该是什么样的(来自Chrome的截图): How it should look like (screenshot from Chrome):

z-index问题(来自Firefox的截图):

z-index issue (screenshot from Firefox)

工件问题,以及带有部分可见轮的工作z-index(来自Firefox的截图): enter image description here enter image description here

将鼠标移到工件(缺失的块)上,就像第一次渲染时一样填充它们。

2 个答案:

答案 0 :(得分:6)

不幸的是,z-ordering在循环层上运行不正常。这是Firefox目前无法处理的一个已知问题。这是一个旧的Firefox错误,你无法解决它,直到他们修复浏览器中的错误。

答案 1 :(得分:2)

与此同时,我找到了一个解决方案,但它不是我想要的,而且它也不是完美的,会出现伪影并通过过渡动画它会产生许多问题。但作为一个静态的&#34;图像&#34;它似乎有效。

基本上,圆圈被绘制两次,一次是蓝色的一半,一次是绿色的一半,但只有一半是可见的。

在Chrome中它的破碎,可以解决......但我只关心firefox。 (这是非常快速和肮脏的编码,我只是再次查看它,并注意到双重声明的函数drawCircle2 ...) https://jsfiddle.net/7w31uLsL/

&#13;
&#13;
$dcw = $(".dcw"); 
var newElement;
var center = 300;
var distance = 200,
  color;
for (var i = 0; i < 360; i = i + 10) {
  color = 20 + Math.round((128 / 360) * i);
  color2 = 220 - Math.round((128 / 360) * i);
  
  $(drawCircle2(color,color2,i,distance)).appendTo($dcw);
}

function drawCircle2(color,color2,rotation,distance) {
	return '<div class="circle" style="transform: translate3d(0,0,0) rotateZ( ' + rotation + 'deg ) translateX('+distance+'px) rotateX(10deg );">' +
  '<div style="background-color: rgba(' + color + ',0,0,1);"></div>' +
  '<div style="background-color: rgba(' + color + ',0,0,1);"></div>' +
 '</div>';
}

function drawCircle2(color,color2,rotation,distance) {
	return '<div class="circle2" style="background-color: rgba(' + color + ',0,0,1);transform: translate3d(0,0,0) rotateZ( ' + rotation + 'deg ) translateX('+distance+'px) rotateX(10deg );">' +
 '</div>';
}
&#13;
.color-wheel {
  width: 600px;
  height: 600px;
  position: relative;
  perspective: 3000px;
  display: block;
}

.dcw {
  top: 0;
  bottom:0;
  height: 100%;
  width: 50%;
  position: absolute;
  transform-style: preserve-3d;
  overflow:hidden;
}
.dcw:first-child {
  right:50%;
  left:0;
}
.dcw:last-child {  
  right:0;
  left:50%;
}

.dcw:first-child .circle2 {
  left: calc(100% - 94px);
}
.dcw:last-child .circle2 {
  left: calc(0% - 94px);
}

.circle2 {
  top: calc(50% - 94px);
  margin: auto;
  position: absolute;
  cursor: pointer;
  transform-style: preserve-3d;
  width: 188px;
  height: 188px;
  border-radius:50%;
  border:1px solid black;
}
.circle {
  top: calc(50% - 94px);
  margin: auto;
  position: absolute;
  cursor: pointer;
  transform-style: preserve-3d;
  width: 188px;
  height: 188px;
  border-radius:50%;
  border:1px solid black;
}
.circle div {
  left:0;
  right:0;
  position: absolute;
  transform-style: preserve-3d;
  width: 100%;
  height: 50%;
}
.circle div:first-child {
  
  border-top-left-radius:1000px;
  border-top-right-radius:1000px;
  top: 0;
  bottom:50%
}
.circle div:last-child {
  border-bottom-left-radius:1000px;
  border-bottom-right-radius:1000px;
  bottom: 0;
  top:50%;
}
&#13;
<script type="text/javascript" src="//code.jquery.com/jquery-git.js"></script>
<div class="color-wheel">
  <div class="dcw" style="background-color:blue;">

  </div>
  <div class="dcw" style="background-color:green;">

  </div>
</div>
&#13;
&#13;
&#13;