【问题标题】:Adding a Product List on Image在图像上添加产品列表
【发布时间】:2019-01-31 11:44:03
【问题描述】:

我在Shopify 中使用minimal template,并希望重新创建附加的此图像。我曾尝试研究类似的例子,但似乎找不到任何东西。我该如何去创建这个图像?如何获取菜单背后的图像?

任何实现图像的链接或文档都会有帮助。

【问题讨论】:

  • 你找到这张图片了吗Image url
  • 你需要学习一下aspect ratios
  • @MohitGupta 是的,那是图片,但我将如何在图片上添加产品列表?

标签: javascript html css shopify shopify-template


【解决方案1】:

尝试分解设计以找出它的组成部分。您需要一张背景图片和一张带有产品卡片的叠加层。您希望通过应用 position:relative to parent 和 position:absolute 来将叠加层放置在图片顶部,以便将其定位在其父级中。然后应用 transform: translate() 根据叠加层的大小来转换叠加层,以实现右侧的偏移量。

这是一支笔:https://codepen.io/NeilWkz/pen/qgRMyW

<div class="img-hero-with-menu-overlay">
 <div class="left-img">
  </div>
  <div class="overlay">
    <div class="product-card">
      <img src="https://lorempixel.com/300/150/" alt="">
      <div class="info">
        <h3>Product 1</h3>
        <p>lorem</p>
      </div>
    </div>
    <div class="product-card">
      <img src="https://lorempixel.com/300/150/" alt="">
      <div class="info">
        <h3>Product 2</h3>
        <p>lorem</p>
      </div>
    </div>
    <div class="product-card">
      <img src="https://lorempixel.com/300/150/" alt="">
      <div class="info">
        <h3>Product 3</h3>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. </p>
      </div>
    </div>
  </div>
</div>

CSS

img-hero-with-menu-overlay {
  position: relative;
  background-color: #bcbdc0;
  width: 100%;
  display: block;
}
.left-img {
  height: 100vh;
  display: block;
  width: 75%;
  background: url("https://www.llialighting.com/Content/files/ProductImages/v_06f3_angled448253599.png")
    no-repeat center center;
  background-size: cover;
}
.overlay {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(-12.5%, -50%);
  width: 40%;
}

.product-card {
  display: flex;
  margin-bottom: 1.5rem;
}

.info {
  padding: 1.5rem;
}

【讨论】:

  • 非常感谢。但是现在它在图片之后添加了一个巨大的灰色空间。如何删除它?
  • 灰色空间在您的设计中。我已经更新了上面的 codepen 和 answer,将背景颜色从 body 移动到 hero 模块。
猜你喜欢
  • 1970-01-01
  • 2022-11-24
  • 2019-02-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-10
  • 2011-02-05
相关资源
最近更新 更多