I am using using the background-image attribute to assign images to a range of div
on my site. However, with background-image
attributes, I also need to assign background-size
to get it looking right.
This works fine mostly, but I need to change the background-size
attribute based on the file type used in the background-image
attribute. For example, as standard I want to user background-size: cover;
but when the background-image
is an SVG I want to use background-size: auto;
Is this possible using CSS attribute selectors? If not, any other solution?
My attempt (SCSS):
&.bg-image {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
min-height: 500px;
max-height: 700px;
&[src$=".svg"] { background-size: auto; }
}