I have a nice background SVG image from inkscape which marks the transition from one text section to the next. I want that background image to scale up or down to the full width of the text section. For reasons of responsivity, that size depends on the browser width. However, I want that background image to have a fixed height of 20px.
What does not work:
background-size: cover;
That does not work for me because it will cut the image off at the right instead of scaling it down, okay.background-size: contain
That does not work for me because it will always scale the image down in x and y direction simultaneously. As a result, the image always retains its original x-y-ratio, okay.- combining
cover
andcontain
That is not possible for syntactical reasons, okay. background-size: 100% 20px;
orbackground-size: auto 20px
That does not work, even though I would have expected it to. I tried it with a PNG and it worked. But with the SVG, the width is being adjusted correctly and the height is then also being adjusted so that the image does retain its original ration, which I do not want it to. However, I wish to use an SVG because it's a relatively simple image and I want it in the best resolution on all devices, including the really big screens, without using a huge PNG image.- As the problem seems to be SVG-specific, I opened the SVG in a text editor and inserted into the tag the attribute and value
preserveAspectRatio="none"
. As it did still not work I also tried removing the width and height and viewBox specifications in the SVG tag. No success.
viewBox
property in the svg? – Dermoid