Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I tried editing the CSS code to fit the video on the mobile screen as the video does not appear in mobile but appears only on desktop.
I am using Dawn template.
I tried this in the base.css file
@media (max-width:500px) {
.video-with-text__media {
padding-top: 100%;
width: 100%;
}
}
DId not work still.
Pls help soon
Hi Anubee123,
Can you provide your store url?
Regards,
Markit-Themes
@anubee123this worked for me.
1. Create a backup:
2. Update the original file:
3. Add required CSS:
4. If anything goes wrong:
Style for main-product.liquid
<style>
@media screen and (min-width: 750px) {
.mobile-only-video {
display: none;
}
}
</style>
Changes to product-thumbnail.liquid
<!-- ... rest of your code ... -->
<div
class="product-media-container media-type-{{ media.media_type }} media-fit-{{ media_fit }} global-media-settings gradient{% if constrain_to_viewport %} constrain-height{% endif %}"
style="--ratio: {{ media.aspect_ratio | default: 1.0 }}; --preview-ratio: {{ media.preview_image.aspect_ratio | default: 1.0 }};"
>
{%- comment -%}
Custom video implementation:
- Replaced deferred-media with direct video element for better mobile/desktop consistency
- Added autoplay, muted, and loop for background-video-like behavior
- Wrapped in deferred-media div to maintain styling/layout
- Removed controls for cleaner look
{%- endcomment -%}
{%- if media.media_type == 'video' -%}
<div class="media media--transparent mobile-only-video" data-media-id="{{ media.id }}">
<video
playsinline="true"
autoplay="true"
muted="true"
loop="true"
preload="none"
poster="{{ media | img_url: '1024x' }}"
alt="{{ media.alt | escape }}"
aria-label="{{ media.alt | escape }}"
>
<source src="{{ media.sources[1].url }}" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
{%- else -%}
<modal-opener
class="product__modal-opener product__modal-opener--{{ media.media_type }}"
data-modal="#ProductModal-{{ modal_id }}"
>
<!-- ... rest of your code ... -->
</modal-opener>
{%- endif -%}
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025