Custom Background Video in Shopify
Liquid Code: copy exactly and paste in the ‘background-video.liquid’ section of your Shopify code. Watch tutorial video on Instagram or YouTube for more information.
<div class="video-hero">
<video autoplay muted loop playsinline class="background-video">
<source src="{{ section.settings.video_url }}" type="video/mp4">
Your browser does not support the video tag.
</video>
<div class="hero-overlay"></div>
<div class="hero-content">
<h2>{{ section.settings.heading }}</h2>
<p>{{ section.settings.subtext }}</p>
{% if section.settings.button_label != blank %}
<a href="{{ section.settings.button_link }}" class="button">{{ section.settings.button_label }}</a>
{% endif %}
</div>
</div>
<style>
.video-hero {
position: relative;
width: 100%;
height: 800px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding-top: 56.25%; /* Forces a perfect 16:9 aspect ratio scale */
overflow: hidden;
}
.background-video {
position: absolute;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: 100%;
height: 100%;
transform: translateX(-50%) translateY(-50%);
z-index: 1;
object-fit: cover;
}
.hero-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4); /* Dark overlay for text readability */
z-index: 2;
}
.hero-content {
position: relative;
z-index: 3;
color: #ffffff;
max-width: 600px;
padding: 20px;
}
.hero-content h2 {
font-size: 3rem;
margin-bottom: 15px;
}
.hero-content p {
font-size: 1.2rem;
margin-bottom: 25px;
}
.hero-content .button {
display: inline-block;
padding: 12px 30px;
background: #BA8854;
color: ##0f2e22;
text-decoration: none;
font-weight: medium;
border-radius: 5px;
}
@media (max-width: 768px) {
.hero-content h2 { font-size: 2rem; }
}
</style>
{% schema %}
{
"name": "Background Video",
"settings": [
{
"type": "text",
"id": "video_url",
"label": "Video File URL",
"info": "Paste the copied URL from your Shopify Files."
},
{
"type": "text",
"id": "heading",
"label": "Heading",
"default": "Your Hero Title"
},
{
"type": "textarea",
"id": "subtext",
"label": "Subtext",
"default": "Tell your brand's story with a captivating video."
},
{
"type": "text",
"id": "button_label",
"label": "Button Label",
"default": "Shop Now"
},
{
"type": "url",
"id": "button_link",
"label": "Button Link"
}
],
"presets": [
{
"name": "Background Video",
"category": "Video"
}
]
}
{% endschema %}
