Reputation: 1625
Here is my list of items :
.anim-box {
margin-top: 5%;
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
.anim-box .item {
display: flex;
flex: 0 0 30%;
flex-direction: column;
justify-content: center;
align-content: center;
text-align: center;
cursor: pointer;
}
.anim-box .item svg,
.anim-box .item img {
height: auto;
width: 100%;
}
<div class="anim-box">
<div class="item"><img id="entry4" src="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg"><span>spin</span></div>
<div class="item"><img id="entry5" src="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg" class="" style=""><span>zoom</span></div>
<div class="item">
<svg>
<image xlink:href="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg"></image>
</svg>
<span>svg</span>
</div>
</div>
Here we have 3 items, the 1st and the 2nd ones are images with the exact same height/width/style. And the last item is an SVG with a different style from the other ones.
Please how can I make the style of the SVG to always be identical to the other ones ? (knowing that the image source is always the same)
Upvotes: 1
Views: 83
Reputation: 272919
You need to add a viewbox to set an aspect ratio to the SVG and it will behave the same as img:
.anim-box {
margin-top: 5%;
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
.anim-box .item {
display: flex;
flex: 0 0 30%;
flex-direction: column;
justify-content: center;
align-content: center;
text-align: center;
cursor: pointer;
}
.anim-box .item svg,
.anim-box .item img {
height: auto;
width: 100%;
}
<div class="anim-box">
<div class="item"><img id="entry4" src="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg"><span>spin</span></div>
<div class="item"><img id="entry5" src="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg" class="" style=""><span>zoom</span></div>
<div class="item">
<svg viewBox="0 0 2048 1356">
<image xlink:href="https://ykob.github.io/glsl-dissolve/img/osaka01.jpg"></image>
</svg>
<span>svg</span>
</div>
</div>
Upvotes: 1