Reputation: 37
I have an html element which is an image . There is no problem seeing the image in mobile, but when you look at the page in computer, the image disappears. I found out the reason this element disappears is when I give it a class="ad_img". there is no style for appearing and disappearing this element inside that class. When I remove class="ad_img" the image shows up.
.ad_img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.ad_main_div {
width: 100%;
max-width: 800px;
}
.ad_main_panel {
background-color: rgba(0, 0, 0, 0.00);
border-radius: 3px;
overflow: hidden;
border: 3px solid rgba(0, 0, 0, 0.00);
display: inline-block !important;
position: relative;
object-fit: cover;
margin-top: 5px;
margin-bottom: 5px;
margin-right: auto;
margin-left: auto;
left: 0px;
right: 0px;
min-width: 100%;
max-width: 800px;
padding-bottom: 12.5%;
}
<center>
<div class="ad_main_div">
<p> With class </p>
<button id="ad_main_button" class="ad_main_panel">
<img src="https://pearlcapital.com/wp-content/uploads/2018/04/FB-Phone-GIF.gif" id="ad_main_img" alt="No Image" class="ad_img"/>
</button>
<p> Without class </p>
<button id="ad_main_button" class="ad_main_panel">
<img src="https://pearlcapital.com/wp-content/uploads/2018/04/FB-Phone-GIF.gif" id="ad_main_img" alt="No Image" />
</button>
</div>
</center>
Upvotes: 2
Views: 1394
Reputation: 11813
The issue you have is that your ad blocker is is preventing the image from displaying.
The ad blocker is using the the ad_img
class to find the element to block.
When I disable my blocker the image displays.
This also explains why it works on your phone, as your phone browser likely doesn't have an ad blocker.
Upvotes: 2
Reputation: 1
Do you have any javascript running in the page changing display to none or visibility to hidden?
The code snippet runs fine here also.
Upvotes: -1