I'd like for an image to only display when the viewport size is less than 768px.
When less than 768px, the image should span the entire width of the window and should not distort (i.e. height should change proportionally with the width).
However, right now, I can't get the height to change when I resize the window.
I've tried changing the display to block and specifying width:100%
, height:auto
.
HTML:
<div class="row col-12" id="mobileimg">
<img src="images/img.png" alt="">
</div>
CSS:
#mobileimg {
display:none;
}
@media only screen and (max-width: 768px) {
#mobileimg {
display:flex;
margin-top:20px;
}
}
Thanks!