SVG as background image to fill entire container

Hi, I’m trying to get this image which was saved as an SVG to fill the entire background, I’ve tried setting the background size to cover/contain but still won’t work. Here’re the CSS code .testimonial-section { background-image: url(images/bg-curve-desktop.svg); background-repeat: no-repeat; background-size: 100% 100%; background-position: center; background-color: orange; } Here’s what I get And here’s what I’m trynna achieve
16 Replies
croganm
croganm17mo ago
What does the svg code look like? See link for why
croganm
croganm17mo ago
Stack Overflow
Background cover is not working correctly
I have a problem : the svg bar isnt responsive (see picture), anyone maybe has a solution for that? I seriously searched for around 1 1/2 hour now and im getting really frustrated :/ Here is my co...
ucheszona
ucheszonaOP17mo ago
@croganm it’s a picture and not really a code. It’s a challenge from frontendmentor
croganm
croganm17mo ago
SVG is actually code if you open it in your editor (whether VSCode or whatever) 🙂 ^
ucheszona
ucheszonaOP17mo ago
I understand you but I mean this one came in a form of an image just like icons and illustration pictures
croganm
croganm17mo ago
You wouldn't be able to open it at all in an editor? I mean I know they are images but they're images made up out of code and everything. It's how we can edit them. The issue is that a lot of SVG's have built in height and widths on them, which makes them pretty inflexible for situations like background images. We would just likely need to delete those attributes and replace it with a viewBox attribute if none exists This way we can morph it
ucheszona
ucheszonaOP17mo ago
Oh, I’ll need you to share and example if you don’t mind, cause it’s really making me think tirelessly
croganm
croganm17mo ago
So this image
croganm
croganm17mo ago
croganm
croganm17mo ago
Really is just the following code:
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M22 22h1v2h-22v-2h1v-8h20v8zm-7-5h-6v6h2v-5h2v5h2v-6zm-9 3h-2v2h2v-2zm14 0h-2v2h2v-2zm-14-4h-2v2h2v-2zm14 0h-2v2h2v-2zm4-3h-24l3-7h3.943l-2.601 2.229.66.771 5.998-5.143v-3.857h5l-1 1.491 1 1.509h-4l6.999 6 .661-.771-2.602-2.229h3.942l3 7zm-12-6.5c1.38 0 2.5 1.12 2.5 2.5s-1.12 2.5-2.5 2.5-2.5-1.12-2.5-2.5 1.12-2.5 2.5-2.5zm0 2.5h1v.8h-1.763v-1.8h.763v1z"/></svg>
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M22 22h1v2h-22v-2h1v-8h20v8zm-7-5h-6v6h2v-5h2v5h2v-6zm-9 3h-2v2h2v-2zm14 0h-2v2h2v-2zm-14-4h-2v2h2v-2zm14 0h-2v2h2v-2zm4-3h-24l3-7h3.943l-2.601 2.229.66.771 5.998-5.143v-3.857h5l-1 1.491 1 1.509h-4l6.999 6 .661-.771-2.602-2.229h3.942l3 7zm-12-6.5c1.38 0 2.5 1.12 2.5 2.5s-1.12 2.5-2.5 2.5-2.5-1.12-2.5-2.5 1.12-2.5 2.5-2.5zm0 2.5h1v.8h-1.763v-1.8h.763v1z"/></svg>
Notice that width and height attribute? You can usually ignore that, but for background images, it's a bit tougher If we delete those attributes, you can size it according to whatever and the SVG will adjust Also, if you don't mind me asking, what's the exact image you're having issues with. I see that orange and blue in your example that's not in the version you're trying to recreate
ucheszona
ucheszonaOP17mo ago
I’m trynna recreate the one with the plain white color but I just don’t know how to go about this cause the image didn’t come with any SVG code , it only came just like a normal photo would, just like an illustration also. Sorry if I’m stressing you out and I appreciate the fact that you trynna help out
croganm
croganm17mo ago
Yea no problem at all. Do you have an example of the site you could show? I know it's a frontend mentor challenge as I've done them myself, but could you drag the folder into this site and send the link? https://app.netlify.com/drop/do
Netlify App
Start building the best web experiences in record time
ucheszona
ucheszonaOP17mo ago
Okay thank, will do that right now
Oladapo Elijah
Oladapo Elijah17mo ago
I am facing the same issue, but I haven't found a solution for it yet. If you have managed to resolve it, could you please share how you handled it? Thanks!
croganm
croganm17mo ago
Yes, I helped him solve it via DM. Unless you have exactly the same project and the exact same problem, I'd recommend creating a new post or DMing me This was a specific case
Oladapo Elijah
Oladapo Elijah17mo ago
Okay.. I will send you a direct message.
Want results from more Discord servers?
Add your server