2011-12-13 53 views
0

我有這個代碼很容易,它根據布爾magento屬性將圖像添加到另一個圖像的一側。如何使用Magento/PHP在另一個圖像上添加圖像?

但是因爲我們運營着一家電子商務商店,所以用戶最喜歡把圖片放在產品上面會更有吸引力。將它們結合在一起。

我不知道如果用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 } ?> 

回答

1

嘗試是這樣的:

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> 
+0

做到這一點將第二個圖像在第一個圖像的頂部水平和垂直居中? – 2011-12-13 21:36:50

1

我不認爲這是可能的PHP,但我想用CSS你可以覆蓋第一個圖像的第二個圖像。

+0

實際上它使一個很大的意義,但我不知道怎麼做,用CSS – 2011-12-13 21:10:49

相關問題