перекрывание svg-объектов
Код svg-картинки:
<svg
width="100%"
height="111.14265mm"
version="1.1"
viewBox="0 0 90.971069 111.14265"
id="svg97"
<g
id="g994">
<rect
x="8.2400427"
y="6.3651724"
width="23.72028"
height="98.379417"
fill="#ffe7e7"
stroke="#000006"
stroke-width="0.506255"
id="rect36"
style="stroke-linejoin:round;stroke-opacity:0.78544" />
<rect
transform="scale(-1)"
x="-30.615013"
y="-63.247421"
width="1.8641548"
height="8.3404837"
fill="url(#radialGradient151593)"
stroke-width="0.284019"
id="rect69"
style="fill:url(#radialGradient151593);stroke:#8a6e3e;stroke-linecap:round;stroke-linejoin:round" />
<rect
x="10.144035"
y="9.4162321"
width="16.67684"
height="91.080803"
fill="url(#radialGradient153802)"
stroke-width="0.80874"
id="rect73"
style="fill:url(#radialGradient153802);stroke:#8a6e3e;stroke-linecap:round;stroke-linejoin:round" />
</g>
<g
fill="#f8f6d3"
stroke-width="0"
id="g91"
transform="matrix(0.53258521,0,0,0.46019001,-11.02889,-13.461654)">
<path
d="M 181.87,149.95 V 43.74 h 7.6717 V 256.16 H 181.87 Z"
id="path81" />
<path
d="m 144.36,43.423 c 6.1226,-0.06739 16.007,-0.06731 21.966,1.55e-4 5.9586,0.06748 0.94926,0.12261 -11.132,0.12252 -12.081,-8.7e-5 -16.956,-0.05528 -10.834,-0.12268 z"
id="path83" />
<path
d="m 22.696,36.491 v -5.5451 h 166.85 v 11.09 H 22.696 Z"
id="path85" />
<path
d="M 22.696,149.95 V 43.74 h 8.4124 V 256.16 H 22.696 Z"
id="path87" />
<path
d="m 22.696,263.63 v -5.7584 h 166.85 v 11.517 H 22.696 Z"
id="path89" />
</g>
</svg>
Код анимации:
@keyframes leftDoorRaspash{
from{
transform: rotateY(0deg) skewY(0deg);
transform-origin: 0% 0%;
}
50%{
transform: rotateY(90deg) skewY(50deg);
transform-origin: 0% 0%;
}
to{
transform: rotateY(0deg) skewY(0deg);
transform-origin: 0% 0%;
}
}
#g994{
animation-name: leftDoorRaspash;
transform-box: fill-box;
animation-duration: 4s;
animation-iteration-count: infinite;
z-index: 3;
}
Каким образом можно сделать так, чтобы анимируемый svg-элемент при движении перекрывал область с заливкой? С элементами path такой проблемы нет, там через z-index решается, но область с заливкой все равно перекрывает анимируемый элемент. Находятся элементы в одном слое.
Ответы (1 шт):
Автор решения: Leonid
→ Ссылка
Я просто перенес дверь (<g id="g994">) в конец SVG. Отрисовка то идет поочередно.
@keyframes leftDoorRaspash{
from{
transform: rotateY(0deg) skewY(0deg);
transform-origin: 0% 0%;
}
50%{
transform: rotateY(90deg) skewY(50deg);
transform-origin: 0% 0%;
}
to{
transform: rotateY(0deg) skewY(0deg);
transform-origin: 0% 0%;
}
}
#g994{
animation-name: leftDoorRaspash;
transform-box: fill-box;
animation-duration: 4s;
animation-iteration-count: infinite;
z-index: 3;
}
<svg
width="100%"
height="111.14265mm"
version="1.1"
viewBox="0 0 90.971069 111.14265"
id="svg97">
<g
fill="#f8f6d3"
stroke-width="0"
id="g91"
transform="matrix(0.53258521,0,0,0.46019001,-11.02889,-13.461654)">
<path
d="M 181.87,149.95 V 43.74 h 7.6717 V 256.16 H 181.87 Z"
id="path81" />
<path
d="m 144.36,43.423 c 6.1226,-0.06739 16.007,-0.06731 21.966,1.55e-4 5.9586,0.06748 0.94926,0.12261 -11.132,0.12252 -12.081,-8.7e-5 -16.956,-0.05528 -10.834,-0.12268 z"
id="path83" />
<path
d="m 22.696,36.491 v -5.5451 h 166.85 v 11.09 H 22.696 Z"
id="path85" />
<path
d="M 22.696,149.95 V 43.74 h 8.4124 V 256.16 H 22.696 Z"
id="path87" />
<path
d="m 22.696,263.63 v -5.7584 h 166.85 v 11.517 H 22.696 Z"
id="path89" />
</g>
<g id="g994">
<rect
x="8.2400427"
y="6.3651724"
width="23.72028"
height="98.379417"
fill="#ffe7e7"
stroke="#000006"
stroke-width="0.506255"
id="rect36"
style="stroke-linejoin:round;stroke-opacity:0.78544" />
<rect
transform="scale(-1)"
x="-30.615013"
y="-63.247421"
width="1.8641548"
height="8.3404837"
fill="url(#radialGradient151593)"
stroke-width="0.284019"
id="rect69"
style="fill:url(#radialGradient151593);stroke:#8a6e3e;stroke-linecap:round;stroke-linejoin:round" />
<rect
x="10.144035"
y="9.4162321"
width="16.67684"
height="91.080803"
fill="url(#radialGradient153802)"
stroke-width="0.80874"
id="rect73"
style="fill:url(#radialGradient153802);stroke:#8a6e3e;stroke-linecap:round;stroke-linejoin:round" />
</g>
</svg>