I have a simple img tag:
<img class="image" src="https://upload.wikimedia.org/wikipedia/commons/b/b6/Image_created_with_a_mobile_phone.png" alt="">
And I have these styles for it:
.image {
width: 200px;
height: 200px;
border-radius: 100%;
border: 10px solid #fff;
}
I want somehow only with css, to hide the image, without hiding the border. And these styles have to be applied only for the image (.image{} selector). This mean that it have to be done without any wrappers.
I know that it sound a little bit strange and unnecessary, but I need it.
I’ve tried the following:
-
"visibility" and "opacity" properties, but they hide the image and the border.
-
Using the rgba() for the border color, and "opacity" and "visibility" again.
-
Putting "opacity = 0" for the image and try to make the borders with ::before and ::after, but I saw that these don’t work for the tags, because they are empty by default.
2
Answers
Set element width and height to be
0px
, but add padding, to keep element dimensions. Than image will be not visible, element will have dimensions and border applied:Use mask: