Here is the HTML I created to showcase a video background with two fallback images for mobile and old browsers:
<div>
<video id="video_background" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0">
<!--<source src="whatever......"> Disabled for testing -->
<img id="browserFallback src="videos/video.gif" title="Your browser does not support the <video> tag">
</video>
<img id="mobileFallback" style="display:none;" src="videos/video.gif" title="Your browser does not support the <video> tag">
</div>
The following JavaScript code is used to display the second image on mobile devices instead of the video:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
document.getElementById("mobileFallback").style.display = "block";
}
However, when both image objects are present simultaneously as shown above, the mobile fallback image becomes misaligned and only half of it gets displayed for some reason. Removing the "browserFallback" image resolves this issue.
Any thoughts on why this could be happening?