I'm exploring the svg <image>
tag for the first time. I've decided to use this tag to apply a gray filter on an image (thanks, IE).
Check out my HTML code below:
<div class="container">
<div class="item">
<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<image xlink:href="https://dummyimage.com/400x400/000/00ffd5.png" />
</svg>
</div>
</div>
Here's the corresponding scss code:
.item {
position: relative;
width: 20%;
height: 220px;
background-color: blue;
}
svg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
image {
width: 100%;
height: 100%;
}
}
I am aiming to make the image fit the parent container, similar to using background: cover in css. Any suggestions?
You can view the result here: https://codepen.io/seabon/pen/QvBBrd
https://i.sstatic.net/vCH43.png
The blue background is set for the div.item
.