Is it possible to make a section background 100% width AND height without cropping? I have a vector image that could stretch with the section.
Thanks!
Is it possible to make a section background 100% width AND height without cropping? I have a vector image that could stretch with the section.
Thanks!
Yes, not only with SVG but with all formats.
My bad, you’re right, it doesn’t work with SVGs.
This article is worth a look.
Thanks!! I will take a look
Here’s the code needed to nuke the aspect ratio.
.stretched-logo-bg {
background: url("../img/curve.svg#svgView(preserveAspectRatio(none))") center center no-repeat;
background-size: 100% 100%;
}
Thank you so much Vincent!! I will try this out!
Hi there,
thats a good solution from vincent there. But I had a case, where this would be very annoying due to some reasons. I found out theres a different approach:
You can open up your SVG in an text editor (Sublime, etc) and hardcode it it directly into your SVG’s.
1. First step, find:
svg width="207px" height="43px"
and change to
svg width="100%" height="100%"
2. Second step, add the attribute preserveAspectRatio=“none” just after width and height as here:
width="100%" height="100%" preserveAspectRatio="none"
3. Third step:
Make your SVG a background image with “cover”
Hope this help
This is golden. Thank you so much!
Amazing Help! Thank you so much
thanks @vincent and ianm, this is extremely useful!! Just the answer I was looking for today
Great!! Thanks, works like a charm
this is literally a live-saver! thank you so much!