php - 如何使用 Magento/PHP 在另一个图像之上添加图像?

标签 php css zend-framework magento

我有这段代码非常简单,它根据 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/

相关文章:

mysql - Zend MySQL 仅在满足所有其他条件时才返回一个值

php - 在 View 中使用 getter 是一种好习惯吗?

php - 使用 XAMPP 从本地主机导入 WP 数据库到免费主机

php - 拉维尔 |具有保留键的PHP数组递归合并

php - 是否需要在 PDO 中测试 execute() 结果?

css 在 asp.net 中的 contentPlaceHolder 的 div 中不起作用

html - 为什么这张表不使用指定的尺寸?

css - jQuery Mobile 中单选按钮的原生外观

zend-framework - zend helper Db_NoRecordExists 用于多表检查

php - Wamp 服务器不会变成绿色