How to scale svg background for react.js app? - css

I have a problem with scaling my background svg image. I would expect it to scale to every browser window size, but right now it doesn't scale vertically no matter what params I set. I already tried removing width and height directly in svg file as stated in Why don't my SVG images scale using the CSS "width" property? and attempted to adjust viewBox and preserveAspectRatio manually, but the image at some point of scaling always ends up with messed up height (for example 1/3 of the full height for mobile devices). Am I doing something wrong with the image or should I simply create another one for different ratios?
My SVG background
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 960 560" enable-background="new 0 0 960 560" xml:space="preserve">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="162.3691" y1="646.5293" x2="893.0117" y2="646.5293" gradientTransform="matrix(0.8443 -0.5359 0.5359 0.8443 -42.54 93.5288)">
<stop offset="0" style="stop-color:#4C0082"/>
<stop offset="0.385" style="stop-color:#4C0382"/>
<stop offset="0.6165" style="stop-color:#4D0B81"/>
<stop offset="0.8074" style="stop-color:#4F1980"/>
<stop offset="0.9753" style="stop-color:#522D7E"/>
<stop offset="1" style="stop-color:#52317E"/>
<stop offset="1" style="stop-color:#52317E"/>
</linearGradient>
<polyline fill="url(#SVGID_1_)" points="822.948,62.45 1303.946,548.438 674.11,919.56 259.071,124.032 "/>
<polyline fill="none" points="111.374,570.263 560.868,-4.484 -31.051,-20.646 -66.404,551.071 -30.041,569.253 111.374,570.263
-338.119,1145.007 "/>
<polyline fill="#11102F" points="1398,-193 696,-193 258.103,-46.896 763.579,458.579 1008.067,314.586 "/>
<polyline fill="#410069" points="1035.566,291.588 334.097,701.066 1301.061,943.584 1213.131,524.346 "/>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-247.6929" y1="273.7153" x2="482.9502" y2="273.7153" gradientTransform="matrix(0.8443 -0.5359 0.5359 0.8443 -42.54 93.5288)">
<stop offset="0" style="stop-color:#4C0082"/>
<stop offset="0.385" style="stop-color:#4C0382"/>
<stop offset="0.6165" style="stop-color:#4D0B81"/>
<stop offset="0.8074" style="stop-color:#4F1980"/>
<stop offset="0.9753" style="stop-color:#522D7E"/>
<stop offset="1" style="stop-color:#52317E"/>
<stop offset="1" style="stop-color:#52317E"/>
</linearGradient>
<polyline fill="url(#SVGID_2_)" points="276.948,-32.55 757.946,453.438 128.11,824.56 -286.929,29.032 "/>
</svg>

Have you tried adding it as a background image via CSS?
.mainElement {
width: 100vw;
height: 100vh;
background: url("https://pixabay.com/get/57e7d0424a50a914ea9d8578c52f317a123ec3e45659704174267cd495/witch-1751025.svg") no-repeat center center;
background-size: cover;
}
<div class="mainElement"></div>
You might want to look into this post https://css-tricks.com/perfect-full-page-background-image/

Take a look at preserveAspectRatio and ensure your html, body, and svg elements are all taking up 100% height of the viewport.
html {
height: 100%;
}
body {
margin: 0;
background: #4C0082;
height: 100%;
}
svg {
height: 100%;
width: 100%;
}
<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 960 560">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="162.3691" y1="646.5293" x2="893.0117" y2="646.5293" gradientTransform="matrix(0.8443 -0.5359 0.5359 0.8443 -42.54 93.5288)"> <stop offset="0" style="stop-color:#4C0082"/> <stop offset="0.385" style="stop-color:#4C0382"/> <stop offset="0.6165" style="stop-color:#4D0B81"/> <stop offset="0.8074" style="stop-color:#4F1980"/> <stop offset="0.9753" style="stop-color:#522D7E"/> <stop offset="1" style="stop-color:#52317E"/> <stop offset="1" style="stop-color:#52317E"/></linearGradient><polyline fill="url(#SVGID_1_)" points="822.948,62.45 1303.946,548.438 674.11,919.56 259.071,124.032 "/><polyline fill="none" points="111.374,570.263 560.868,-4.484 -31.051,-20.646 -66.404,551.071 -30.041,569.253 111.374,570.263 -338.119,1145.007 "/><polyline fill="#11102F" points="1398,-193 696,-193 258.103,-46.896 763.579,458.579 1008.067,314.586 "/><polyline fill="#410069" points="1035.566,291.588 334.097,701.066 1301.061,943.584 1213.131,524.346 "/><linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-247.6929" y1="273.7153" x2="482.9502" y2="273.7153" gradientTransform="matrix(0.8443 -0.5359 0.5359 0.8443 -42.54 93.5288)"> <stop offset="0" style="stop-color:#4C0082"/> <stop offset="0.385" style="stop-color:#4C0382"/> <stop offset="0.6165" style="stop-color:#4D0B81"/> <stop offset="0.8074" style="stop-color:#4F1980"/> <stop offset="0.9753" style="stop-color:#522D7E"/> <stop offset="1" style="stop-color:#52317E"/> <stop offset="1" style="stop-color:#52317E"/></linearGradient><polyline fill="url(#SVGID_2_)" points="276.948,-32.55 757.946,453.438 128.11,824.56 -286.929,29.032 "/>
</svg>

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,iVBORw0KGgoAAAANSUhEUgAAAUAAAAFACAYAAADNkKWqAAAZtUlEQVR4nO3df2id133H8XcT0ZlOlJviFlFEUcBQr7AiRv7w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zN0LhRQ+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 crop an image width svg?

How to crop an image with path in this svg?
<svg width="1440" height="568" viewBox="0 0 1440 568" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0H1440V481.821L720 568L0 481.821V0Z" fill="url(#paint0_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="720" y1="607.026" x2="720" y2="35.2649" gradientUnits="userSpaceOnUse">
<stop stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="#0997FF" stop-opacity="0.56"/>
</linearGradient>
</defs>
</svg>
I want to set linearGradient of svg on an image and extra space in bottom of image be as same as background color of body(navy blue):
<div class="bg"></div>
.bg {
width: 100vw;
min-height: 500px;
background: url("../assets/images/mySvg.svg"),
url("../assets/images/myImage.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
What I have:
What I want:
Put the image into the SVG.
Combine the image and the gradient into an SVG group (<g>)
Then clip that group with an SVG <clipPath> defined using your original path.
Put the SVG inside the <div>
body {
background-color: linen;
}
.bg {
width: 100vw;
min-height: 500px;
}
<div class="bg">
<svg width="100%" viewBox="0 0 1440 568">
<defs>
<clipPath id="clip">
<path d="M0 0H1440V481.821L720 568L0 481.821V0Z"/>
</clipPath>
<linearGradient id="paint0_linear" x1="720" y1="607.026" x2="720" y2="35.2649" gradientUnits="userSpaceOnUse">
<stop stop-color="white" stop-opacity="0"/>
<stop offset="1" stop-color="#0997FF" stop-opacity="0.56"/>
</linearGradient>
</defs>
<g clip-path="url(#clip)">
<image xlink:href="http://placekitten.com/1440/568" width="1440" height="568"/>
<rect width="1440" height="568" fill="url(#paint0_linear)"/>
</g>
</svg>
<p>More content here.</p>
</div>

SVG linearGradient with animation keyframes together

I create simple example where use two path sec1 and sec2. For both path I use linearGradient with id step1 and step2. First part (sec1) work great, second part (sec2) not yet.
Sec2 must first be in hide, then change positions and scale. I try do this by keyframing, but can't hide sec2 in beginning. Also if I try to use in linearGradient attribute begin="step1.end;" it not working, and not running after filling sec1.
I want create like one animation line which begin from left to right and then from top to bottom, with first change sec2 postion and scale (in hide) after this begin drawing and show gradient animation.
My example here:
https://jsfiddle.net/0gkrch42/
You had two main problems...
Your second animation didn't start hidden because you had the gradient offset starting at "40%' instead of zero
The second problem was that when you use id.end for timing attributes, the id has to reference another <animation> element, not a graphics element.
<svg id="Logo-Defs" version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="step1" x1="0" y1="0" x2="1" y2="0">
<stop offset="40%" stop-opacity="1" stop-color="black">
<animate attributeName="offset" values="0;1" repeatCount="1" fill="freeze" dur="5s" begin="0s" />
</stop>
<stop offset="40%" stop-opacity="0" stop-color="black">
<animate id="anim1" attributeName="offset" values="0;1" repeatCount="1" fill="freeze" dur="5s" begin="0s" />
</stop>
</linearGradient>
<linearGradient id="step2" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-opacity="1" stop-color="black">
<animate attributeName="offset" values="0;1" repeatCount="1" fill="freeze" dur="5s" begin="anim1.end;" />
</stop>
<stop offset="0%" stop-opacity="0" stop-color="black">
<animate attributeName="offset" values="0;1" repeatCount="1" fill="freeze" dur="5s" begin="anim1.end;" />
</stop>
</linearGradient>
<g>
<path id="sec1" class="cls-1" d="M155.06,43V41.83A42.78,42.78,0,0,0,143.12,16.5c-10.62-11.07-26-12-26-12S10.86,5,3.3,5C3.27,5,.44.25.44.25L117.08.73C137,2,158,18.38,159.07,43,158.09,43,156.08,43,155.06,43Z" />
<path id="sec2" class="cls-1" d="M159.22,129.83V43.18h-4.06q.11,43.42.22,86.84,0,1.89,0,3.78v.91h3.82Z" />
</g>
</defs>
</svg>
<svg id="svg" class="Animate-Path" width="100%" height="100%" viewBox="0 0 512 650" xml:space="preserve">
<use id="Draw-sec1" xlink:href="#sec1" fill="url(#step1)" />
<use id="Draw-sec2" xlink:href="#sec2" fill="url(#step2)" />
<!--<use class="Animate-Fill" xlink:href="#Logo-Group" /> -->
</svg>

SVG Image opacity gradient

I'm using this bit of code in an .svg file to apply a opacity fade out gradient on an element. The following code works well, but fades from left to right instead of vertically from top to bottom.
What code change would I need to make to achieve this? Thanks for the help!
SVG file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1"
baseProfile="full">
<mask id="m1" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">
<linearGradient id="g" gradientUnits="objectBoundingBox" x2="1">
<stop stop-color="white" offset="0"/>
<stop stop-color="white" stop-opacity="0" offset="1"/>
</linearGradient>
<rect x="0" y="0" width="1" height="1" fill="url(#g)"/>
</mask>
</svg>
CSS:
mask: url(/mypath/mask.svg#m1);
You set the direction of a gradient with the x1,y1,x2 and y2 attributes.
For a vertical gradient starting at the top and going down you need to go from (0,0) to (0,1).
<linearGradient id="g" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="white" offset="0"/>
<stop stop-color="white" stop-opacity="0" offset="1"/>
</linearGradient>

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