【问题标题】:Add a link to vimeo video on Shopify在 Shopify 上添加指向 vimeo 视频的链接
【发布时间】:2021-11-14 06:36:43
【问题描述】:

在我们的网站上,我们使用 vimeo 在我们的主页上显示“签名样式”的轮播视频。我想添加一个链接,以便当您单击此视频时,它将引导您进入“签名样式”页面。

我不熟悉使用 Liquid/shopify。我知道如何在 HTML 中执行此操作,但它似乎不像我想象的那样工作。

这是“background-video.liquid”文件中的原始代码:

<section class="Section" id="section-{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="background-video" data-section-settings='{{ section_settings }}'>
  <div class="ImageHero {% if section.settings.section_size != 'normal' %}ImageHero--{{ section.settings.section_size }}{% endif %}">
    <div class="ImageHero__VideoHolder"></div>
  </div>
</section>

这是我尝试用以下代码替换上述行的一些代码:

<a href="https://www.clarasunwoo.com/search?q=signature+styles&type=product">
<div style="padding:56.25% 0 0 0;position:relative;">

<iframe src="https://vimeo.com/540236561" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

</div><script src="https://player.vimeo.com/api/player.js"></script>
</a>

【问题讨论】:

标签: html shopify liquid vimeo


【解决方案1】:

您需要做的就是创建一个覆盖 div,“阻止”实际 iframe 通过 z-index 与之交互。然后您可以使用 JavaScript 来处理用户的点击和重定向。

<div style="padding: 56.25% 0 0 0; position: relative">
    <iframe
    src="https://vimeo.com/540236561"
    style="
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    "
    frameborder="0"
    allow="autoplay; fullscreen"
    allowfullscreen
    ></iframe>

    <div class="overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 99;"></div>
</div>
<script src="https://player.vimeo.com/api/player.js"></script>

<script>
    const overlay = document.querySelector(".overlay");

    overlay.onclick = function () {
    window.location.href = "https://www.clarasunwoo.com/search?q=signature+styles&type=product";
    };
</script>

【讨论】:

  • 希望我没有误解这个问题。
  • 我更新了叠加层的样式,第一次忘记添加了。
  • 谢谢!我会用这些新行替换我以前的代码吗?老实说,我讨厌 shopify 液体。我已经习惯了 JavaScript/HTML/CSS 哈哈
  • 我收到错误:拒绝在框架中显示“vimeo.com”,因为它将“X-Frame-Options”设置为“sameorigin”。在我的控制台中
  • 是的,我在加载 iframe 时遇到了问题,同样的问题。我不确定它为什么会这样做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-27
  • 1970-01-01
  • 2014-08-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多