Note that when running all snippets below, to get a full understanding of the issue: please view on mobile-view (example, use toggle device toolbar feature from chrome developer tools).
This image is fine (not using meta viewport)
.image-ok {
height: 300px;
width: 300px;
background-color: purple;
}
<html>
<body>
<img class="image-ok" src="https://i.ibb.co/mTPWBWC/shirt.png">
</body>
</html>
However, when I used the code <meta name="viewport" content="width=1440">
and viewed the page on mobile view (i.e., let the meta viewport kick in)
borders on the transparent image start appearing ...
Here is the sample that produces the unwanted borders:
.image-not-ok {
background-color: black;
}
<html>
<head>
<meta name="viewport" content="width=1440">
</head>
<body>
<img class="image-not-ok" src="https://i.ibb.co/mTPWBWC/shirt.png">
</body>
</html>
Question: Why does this happen and how can I use CSS to prevent such borders from appearing?
Note:
I've fixed this using the following methods:
inline-block
element.image-wrapper {
display: inline-block;
overflow: hidden;
backface-visibility: hidden;
}
.image-ok {
background-color: black;
transform: scale(1.02);
}
.image-wrapper {
display: inline-block;
overflow: hidden;
backface-visibility: hidden;
}
.image-ok {
background-color: black;
transform: scale(1.02);
}
<div class="image-wrapper">
<img class="image-ok" src="https://i.ibb.co/mTPWBWC/shirt.png">
</div>