CSS 3D isometric simple rotation transform - css

I am trying to do a small CSS animation with a door like folding animation. I use a SVG as the base, gave it an isometric transform and now I would like the orange square to fold as if it was a 3D space.
I tried to play with perspective, skewing, transform 3D but failed.
#svgbox {
position: absolute;
transform: rotate(-45deg) skew(15deg, 15deg);
left: 200px;
}
#rect5 {
animation: rect5anim 3s ease forwards;
transform-origin: 0% 50%;
perspective: 1500px;
/*transform-style: preserve-3d;*/
}
#keyframes rect5anim {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(-180deg);
}
}
<div id="svgbox">
<svg viewBox="0 0 1200 1200" width="400" height="400" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient x1="123.587715%" y1="49.9380835%" x2="24.1186732%" y2="49.9380835%" id="linearGradient-1" gradientTransform="rotate(45)">
<stop stop-color="#F6851F" offset="0%"></stop>
<stop stop-color="#F59427" offset="28.32%"></stop>
<stop stop-color="#F5BB42" offset="100%"></stop>
</linearGradient>
<linearGradient x1="126.190394%" y1="50.060688%" x2="22.2418719%" y2="50.060688%" id="linearGradient-2" gradientTransform="rotate(45)">
<stop stop-color="#F6851F" offset="0%"></stop>
<stop stop-color="#F5BB42" offset="100%"></stop>
</linearGradient>
<linearGradient x1="122.778325%" y1="50.0081081%" x2="24.5036946%" y2="50.0081081%" id="linearGradient-3" gradientTransform="rotate(45)">
<stop stop-color="#8CC151" offset="0%"></stop>
<stop stop-color="#98C54C" offset="14.59%"></stop>
<stop stop-color="#D7DF23" offset="99%"></stop>
</linearGradient>
<linearGradient x1="-27.65086%" y1="50.0081081%" x2="72.4520885%" y2="50.0081081%" id="linearGradient-4" gradientTransform="rotate(45)">
<stop stop-color="#8CC151" offset="0%"></stop>
<stop stop-color="#D7DF23" offset="99%"></stop>
</linearGradient>
</defs>
<g>
<rect id="rect1" width="200" height="200" fill="url(#linearGradient-1)" />
<rect id="rect2" x="201" width="200" height="200" fill="url(#linearGradient-1)" />
<rect id="rect3" x="401" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect4" x="601" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect5" x="801" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect6" y="201" width="200" height="200" fill="url(#linearGradient-3)" />
<rect id="rect7" y="401" width="200" height="200" fill="url(#linearGradient-4)" />
<rect id="rect8" y="601" width="200" height="200" fill="url(#linearGradient-4)" />
</g>
</svg>
</div>

The problem is because you are using the perspective property and not applying perspective to the transform (transform: perspective(x)). The perspective property does not affect the rendering of an element. It only creates a 3D space that will be used by its children. You can find more information about this in this CSS Tricks Article.
Another thing that might be worth noting is that percentage values for transform-origin don't seem to work well in Firefox. It requires px based values and that too it should be in reference to the SVG's (0,0). So, for #rect5, setting transform-origin: 801px 100px produces the expected output in FF. This CSS Tricks Article has detailed information about this particular problem.
Below is a snippet which uses transform with a perspective in-order to produce the needed effect.
#svgbox {
position: absolute;
transform: rotate(-45deg) skew(15deg, 15deg);
left: 200px;
}
#rect5 {
animation: rect5anim 3s ease forwards;
transform-origin: 801px 100px;
transform-style: preserve-3d;
}
#keyframes rect5anim {
0% {
transform: perspective(1000px) rotateY(0deg);
}
100% {
transform: perspective(1000px) rotateY(180deg);
}
}
<div id="svgbox">
<svg viewBox="0 0 1200 1200" width="400" height="400" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient x1="123.587715%" y1="49.9380835%" x2="24.1186732%" y2="49.9380835%" id="linearGradient-1" gradientTransform="rotate(45)">
<stop stop-color="#F6851F" offset="0%"></stop>
<stop stop-color="#F59427" offset="28.32%"></stop>
<stop stop-color="#F5BB42" offset="100%"></stop>
</linearGradient>
<linearGradient x1="126.190394%" y1="50.060688%" x2="22.2418719%" y2="50.060688%" id="linearGradient-2" gradientTransform="rotate(45)">
<stop stop-color="#F6851F" offset="0%"></stop>
<stop stop-color="#F5BB42" offset="100%"></stop>
</linearGradient>
<linearGradient x1="122.778325%" y1="50.0081081%" x2="24.5036946%" y2="50.0081081%" id="linearGradient-3" gradientTransform="rotate(45)">
<stop stop-color="#8CC151" offset="0%"></stop>
<stop stop-color="#98C54C" offset="14.59%"></stop>
<stop stop-color="#D7DF23" offset="99%"></stop>
</linearGradient>
<linearGradient x1="-27.65086%" y1="50.0081081%" x2="72.4520885%" y2="50.0081081%" id="linearGradient-4" gradientTransform="rotate(45)">
<stop stop-color="#8CC151" offset="0%"></stop>
<stop stop-color="#D7DF23" offset="99%"></stop>
</linearGradient>
</defs>
<g>
<rect id="rect1" width="200" height="200" fill="url(#linearGradient-1)" />
<rect id="rect2" x="201" width="200" height="200" fill="url(#linearGradient-1)" />
<rect id="rect3" x="401" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect4" x="601" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect5" x="801" width="200" height="200" fill="url(#linearGradient-2)" />
<rect id="rect6" y="201" width="200" height="200" fill="url(#linearGradient-3)" />
<rect id="rect7" y="401" width="200" height="200" fill="url(#linearGradient-4)" />
<rect id="rect8" y="601" width="200" height="200" fill="url(#linearGradient-4)" />
</g>
</svg>
</div>

Related

How to handle responsive svg type image in side div tag

i am supposed to create this card using CSS. following you can see Figma UI design of it.
following you can see my code part of it (I have used one mudblazor icon for this )
<div class="dashboard-tile-card">
<div class="dashboard-tile-icon ">
<img src="/img/moneybag.svg" width="50%" />
</div>
<div class="dashboard-card-action">
<a class="text-white">Go to the Dashboard</a><MudIcon Style="#($"color:{Colors.Grey.Lighten5};")" Icon="#Icons.Filled.ArrowForward"></MudIcon>
</div>
</div>
moneybag.svg
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g filter="url(#filter0_b_0_1)">
<circle cx="60" cy="60" r="60" fill="url(#paint0_radial_0_1)"/>
<circle cx="60" cy="60" r="58.5" stroke="url(#paint1_radial_0_1)" stroke-width="3"/>
<circle cx="60" cy="60" r="58.5" stroke="url(#paint2_radial_0_1)" stroke-width="3"/>
<circle cx="60" cy="60" r="58.5" stroke="url(#paint3_linear_0_1)" stroke-width="3"/>
</g>
<rect x="30" y="30" width="60" height="60" fill="url(#pattern0)"/>
<defs>
<filter id="filter0_b_0_1" x="-42" y="-42" width="204" height="204" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImage" stdDeviation="21"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_0_1"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur_0_1" result="shape"/>
</filter>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_0_1" transform="scale(0.003125)"/>
</pattern>
<radialGradient id="paint0_radial_0_1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(1.07937 3.57024) rotate(44.0741) scale(162.963 260.636)">
<stop stop-color="white" stop-opacity="0.4"/>
<stop offset="1" stop-color="white" stop-opacity="0"/>
</radialGradient>
<radialGradient id="paint1_radial_0_1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(1.07937 3.57024) rotate(44.0741) scale(162.963 260.636)">
<stop stop-color="#D8D8D8" stop-opacity="0"/>
<stop offset="1" stop-color="#D8D8D8"/>
</radialGradient>
<radialGradient id="paint2_radial_0_1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(1.65079 116.331) rotate(-44.0635) scale(162.139 259.045)">
<stop stop-color="#D8D8D8" stop-opacity="0"/>
<stop offset="1" stop-color="#D8D8D8"/>
</radialGradient>
<linearGradient id="paint3_linear_0_1" x1="2.22222" y1="3.27273" x2="141.088" y2="66.7179" gradientUnits="userSpaceOnUse">
<stop stop-color="white" stop-opacity="0.9"/>
<stop offset="1" stop-color="white" stop-opacity="0"/>
</linearGradient>
<image id="image0_0_1" width="320" height="320" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAAFACAYAAADNkK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mwXNuxWed2d6OD4XPVaaHxMzgeFJ4bJcA03QO8d8XnBoEJh1ikNzN0LhRQ+10VVaQEWB0bgC3r/J3Wesb1aK1jZ92UdWrtlljrGpUtD5UbJcA83RvgGjexPCvu7Ri2m6Hlzeaf1/b4ufvChyYpUwKUfjVIZ0KntZdVREREuvF/rw9J5TJv+e4AAAAASUVORK5CYII="/>
</defs>
</svg>
CSS file
.dashboard-tile-card {
width: 100%;
height: 100%;
background: #FFFFFF;
border: 1.5px solid #c2c2c2;
border-radius: 12px;
}
.dashboard-tile-icon {
display: flex;
justify-content: center;
align-items: center;
height: 75%;
}
.dashboard-card-action {
background: #063b71ff;
height: 25%;
border-radius: 0 0 12px 12px;
display: flex;
justify-content: center;
align-items: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
I am not much good at the CSS side.i think I am doing some wrong CSS rules for this. my issue is I can't maintain the responsiveness of the image .some screen size svg image will be very small and for some screen sizes, this image will break the margin of the outside border.
please does anybody know how to do this very smart way instead of this? it should be responsive to whatever screen sizes
Try import this icon from figma in svg but inspect source code with browser. Then copy this small code and paste it in dashboard-tile-icon. Next what you want to do is removing height and width in svg tag and and give it in css using % if you want it responsive but I like this type of icons always keeps in between 50px and 80px.

How to make animated, gradient filled, SVG donut chart

I was trying to find clean simple solution to create SVG kind of donut charts with gradient fill going along the edge of the circle with the possibility to animate it from 0% to x% and I found out that there's no easy way and no ready copy & paste solution. Most solution used one linear gradient, which didn't help in my case or were over complicated.
The kind of (static) result I expected to get was:
So after some research and work I created this solution which I decided to share it with you.
It is based on the prozorov's solution. His circle wasn't 360deg and lacked the needed animation part. It isn't true gradient going with the stroke around the edge of the circle (which is not easy to do with SVG) but rather two linear gradients put together, but for most cases that trick does it.
And here's the complete solution:
.animated {
animation: dash 5s infinite;
}
#keyframes dash {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 1570;
}
100% {
stroke-dashoffset: 0;
}
}
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="800" width="800">
<defs>
<linearGradient id="Gradient1" gradientTransform="rotate(90)">
<stop offset="0%" stop-color="#ff0000"/>
<stop offset="100%" stop-color="#00ff00"/>
</linearGradient>
<linearGradient id="Gradient2" gradientTransform="rotate(90)">
<stop offset="0%" stop-color="#0000ff"/>
<stop offset="100%" stop-color="#00ff00"/>
</linearGradient>
<pattern id="Pattern" x="0" y="0" width="600" height="600" patternUnits="userSpaceOnUse">
<g transform="rotate(0, 300, 300)">
<rect shape-rendering="crispEdges" x="0" y="0" width="300" height="600" fill="url(#Gradient1)"/>
<rect shape-rendering="crispEdges" x="300" y="0" width="300" height="600" fill="url(#Gradient2)"/>
</g>
</pattern>
</defs>
<path id='arc5' class="animated"
style="stroke: url(#Pattern);" fill='transparent'
stroke-dasharray="1570 1570"
stroke-dashoffset="0"
stroke-width='60'
d='M 300 58 A 250 250 0 1 1 299.99 58'/>
</svg
And link to JS Fiddle

Rotating the stroke but not the filling of a svg circle

I've followed this tuto in order to implement a progress ring for my Vue application. I still have an extra requirement: fill the circle with an image. That's the point I've reached to, using a pattern (copy pasted from my browser in order to avoid adding the extra complexity of Vue property evaluations):
HTML
<div>
<svg
height="600"
width="600">
<defs>
<pattern id="service" x="0%" y="0%" height="100%" width="100%"
viewBox="0 0 100 100">
<image x="5" y="5" width="90" height="90" href="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Selfie_icon.svg/2000px-Selfie_icon.svg.png"></image>
</pattern>
<linearGradient id="gradient">
<stop offset="0%" stop-color="#f6921e"/>
<stop offset="100%" stop-color="#f6921e88"/>
</linearGradient>
</defs>
<circle
stroke="url(#gradient)"
stroke-dasharray="1709.0264035528476 1709.0264035528476"
style="stroke-dashoffset: 512.708;"
stroke-linecap="round"
stroke-width="14"
fill="url(#service)"
r="272"
cx="300"
cy="300"
/>
</svg>
</div>
CSS
circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
However, I find that rotating the circle obviously rotates its filling too.
Is there any way to overcome this problem? Why does the example rotate the entire SVG to make the circle gap be in the upside?
Codepen
You can use another circle in your SVG, one for the border and one for the background, then rotate just the circle with the border:
.circle-border {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
<!-- begin snippet: js hide: false console: true babel: false -->
<div>
<svg height="600" width="600">
<defs>
<pattern id="service" x="0%" y="0%" height="100%" width="100%" viewBox="0 0 100 100">
<image x="5" y="5" width="90" height="90" href="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Selfie_icon.svg/2000px-Selfie_icon.svg.png"></image>
</pattern>
<linearGradient id="gradient">
<stop offset="0%" stop-color="#f6921e"/>
<stop offset="100%" stop-color="#f6921e88"/>
</linearGradient>
</defs>
<circle
stroke="url(#gradient)"
stroke-dasharray="1709.0264035528476 1709.0264035528476"
style="stroke-dashoffset: 512.708;"
stroke-linecap="round"
stroke-width="14"
fill="transparent"
class="circle-border"
r="272"
cx="300"
cy="300"
/>
<circle
stroke-width="0"
fill="url(#service)"
class="circle-bg"
r="272"
cx="300"
cy="300"
/>
</svg>
</div>

SVG <animate> offset from 0 not working

The purpose of the animation is that fill background colour as loading battery. The solution seems to me apple gradient animation which shows as loading. But in the current SVG linearGradient animate not working when attribute offset="0%"
div {
float: left;
width: 50%;
padding: 10px;
box-sizing: border-box;
}
<div>
<p><small>offset from 0%</small> <strong>not working</strong></p>
<svg viewBox="0 0 110 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="mysvg">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Group" fill="#EAEAEA">
<rect id="Brick-4" x="77.5" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-3" x="56" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-2" x="34.5" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-1" x="13" y="10" width="13.5" height="68" rx="3"></rect>
<path d="M104,30.2724875 C104.164709,30.2576038 104.331485,30.25 104.5,30.25 C107.537566,30.25 110,32.7220822 110,35.7458573 L110,53.1708094 C110,56.2060875 107.531385,58.6666667 104.5,58.6666667 C104.331455,58.6666667 104.164681,58.6590557 104,58.6441617 L104,82.0033234 C104,85.3151964 101.311488,88 97.9970362,88 L6.0029638,88 C2.68761844,88 0,85.3182852 0,82.0033234 L0,5.99667663 C0,2.68480358 2.68851188,0 6.0029638,0 L97.9970362,0 C101.312382,0 104,2.68171476 104,5.99667663 L104,30.2724875 L104,30.2724875 Z M5,10.991014 C5,7.68226832 7.68678744,5 11.0051618,5 L92.9948382,5 C96.3113975,5 99,7.68493655 99,10.991014 L99,77.008986 C99,80.3177317 96.3132126,83 92.9948382,83 L11.0051618,83 C7.68860254,83 5,80.3150634 5,77.008986 L5,10.991014 Z"
fill="url(#fromzero)
"></path>
<defs>
<linearGradient id="fromzero" x1="0">
<stop offset="0%" stop-color="#4c7eaf"></stop>
<stop offset="0%" stop-color="#828282"></stop>
<animate attributeName="x1" dur="5s" from="0%" to="100%" repeatCount="indefinite" />
</linearGradient>
</defs>
</g>
</g>
</svg>
</div>
<div>
<p><small>offset from 1%</small> <strong>working</strong></p>
<svg viewBox="0 0 110 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="mysvg">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Group" fill="#EAEAEA">
<rect id="Brick-4" x="77.5" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-3" x="56" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-2" x="34.5" y="10" width="13.5" height="68" rx="3"></rect>
<rect id="Brick-1" x="13" y="10" width="13.5" height="68" rx="3"></rect>
<path d="M104,30.2724875 C104.164709,30.2576038 104.331485,30.25 104.5,30.25 C107.537566,30.25 110,32.7220822 110,35.7458573 L110,53.1708094 C110,56.2060875 107.531385,58.6666667 104.5,58.6666667 C104.331455,58.6666667 104.164681,58.6590557 104,58.6441617 L104,82.0033234 C104,85.3151964 101.311488,88 97.9970362,88 L6.0029638,88 C2.68761844,88 0,85.3182852 0,82.0033234 L0,5.99667663 C0,2.68480358 2.68851188,0 6.0029638,0 L97.9970362,0 C101.312382,0 104,2.68171476 104,5.99667663 L104,30.2724875 L104,30.2724875 Z M5,10.991014 C5,7.68226832 7.68678744,5 11.0051618,5 L92.9948382,5 C96.3113975,5 99,7.68493655 99,10.991014 L99,77.008986 C99,80.3177317 96.3132126,83 92.9948382,83 L11.0051618,83 C7.68860254,83 5,80.3150634 5,77.008986 L5,10.991014 Z"
fill="url(#fromone)
"></path>
<defs>
<linearGradient id="fromone" x1="0">
<stop offset="1%" stop-color="#4c7eaf"></stop>
<stop offset="1%" stop-color="#828282"></stop>
<animate attributeName="x1" dur="5s" from="0%" to="100%" repeatCount="indefinite" />
</linearGradient>
</defs>
</g>
</g>
</svg>
</div>
Chaning the code to this
<linearGradient id="fromzero" x1="0">
<stop offset="50%" stop-color="#4c7eaf"></stop>
<stop offset="50%" stop-color="#828282"></stop>
<animate attributeName="x1" dur="5s" from="-100%" to="100%" repeatCount="indefinite" />
</linearGradient>
Makes the gradient split the background-color in the two colors, and moves it from -100% to 100%, making it possible to go from 0% to 100%, while giving it the exact same effect.
I've now also added the animation you wanted. It is being triggered by clicking on the svg element.
Here's a Fiddle of the result
Hope this helps

compass/css fade border at edges?

I've seen this technique used quite a lot. Like say a separator border (like bottom border for stackoverflow header) which fades at both ends. How do I achieve this with compass? I've searched their documentation and google and can't find any examples of how to do this.
I've never used Compass CSS, but how about mixing CSS and SVG?
Your SVG file:
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="div" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:rgb(255, 255, 225);stop-opacity:0"/>
<stop offset="50%" style="stop-color:rgb(153,153,153);stop-opacity:1"/>
<stop offset="100%" style="stop-color:rgb(255, 255, 225);stop-opacity:0"/>
</linearGradient>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="url(#div)" />
</svg>
The CSS:
div.separator
{
width: 80%;
height: 16px;
background-image: url(gradient_file.svg);
}

Resources