A user encountered a white line appearing below a custom CSS video element on mobile devices, though it displayed correctly on desktop. The issue was resolved by adding specific CSS code to the theme’s base.css file:
Solution provided:
Navigate to Shopify admin → Online Store → Themes → Edit code
Add CSS targeting .multicolumn .page-width with margin-top: -1px !important within a media query for screens with max-width 989px
This negative margin removes the unwanted white space
Additional tip shared:
The original poster also addressed a related issue where videos don’t autoplay on iPhones in low power mode. They shared a JavaScript workaround that triggers video playback when users touch the screen or scroll, implemented by adding event listeners to the theme.liquid file before the closing </body> tag.
Both solutions were confirmed working by the original poster.
Summarized with AI on November 6.
AI used: claude-sonnet-4-5-20250929.
I’m using a custom css video with a shop button on my homepage. It works perfectly on a desktop but when viewed on mobile you can see a white line under the video before the next header.
Here’s the code i’m using for the video. What do I need to change to remove the white line in the screenshot below?
Also thought i’d share… was struggling with another issue around the video not autoplaying on an iPhone if its in low power mode. There isn’t a full solution but there is a workaround.
If you add this code to your theme.liquid near the bottom before the tag, then if the device is in low power mode, once the user touches anywhere on the screen or scrolls the video will autoplay and stay playing.
<script>
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
get: function () {
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
}
});
document.body.addEventListener("click", playVideoOnLowPower);
document.body.addEventListener("touchstart", playVideoOnLowPower);
function playVideoOnLowPower(){
try{
const videoElements = document.querySelectorAll("video");
for (i = 0; i < videoElements.length; i++) {
if (videoElements[i].playing) {
} else {
videoElements[i].play();
}
}
}
catch(err) {
console.log(err);
}
}
</script>