我有这段代码非常简单,它根据 bool magento 属性将一个图像添加到另一个图像的一侧。
但因为我们经营的是电子商务商店,所以将图片放在产品顶部对用户更具吸引力。将它们组合在一起。
我想知道使用 PHP 是否可以做到这一点。 有人建议使用 CSS 叠加图像吗?
<div class="product-img-box">
<?php echo $this->getChildHtml('media') ?>
</div>
<?php $Deal = $_product->getResource()->getAttribute('deal')->getFrontend()->getValue($_product);?>
<?php if($Deal == 'Yes'){ ?>
<img src="<?php echo $this->getSkinUrl('images/icon-deal.gif') ?>" >
<?php } ?>
最佳答案
尝试这样的事情:
CSS
.product-img-box{position: relative;}
.overlay{z-index: 100; left: 0px; top: 0px; position: absolute;}
PHP
<div class="product-img-box">
<?php echo $this->getChildHtml('media') ?>
<?php $Deal = $_product->getResource()->getAttribute('deal')->getFrontend()->getValue($_product);?>
<?php if($Deal == 'Yes'){ ?>
<img class="overlay" src="<?php echo $this->getSkinUrl('images/icon-deal.gif') ?>" >
<?php } ?>
</div>
关于php - 如何使用 Magento/PHP 在另一个图像之上添加图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8496122/