2017-08-05 51 views

回答

0

嘗試將此項添加到您的CSS:

a.button.product_type_variable.add_to_cart_button{ 
    position:relative; 
    top:-11em; 
} 

您可以調整top值...但11em看起來像您希望的位置。


編輯

你說得對!我沒有嘲笑它。
所以它必須與jQuery和一點點計算。

$("a.button.product_type_variable.add_to_cart_button").each(function(){ 
    var imageAbove = $(this).closest("li").find("img"); 
    var imageAbovePos = imageAbove.offset().top; 
    var imageAboveHeight = imageAbove.height(); 

    var thisPos = $(this).offset().top; 
    var thisHeight = $(this).height(); 

    // Position of the bottom of the image 
    var imageAboveBottom = imageAbovePos + imageAboveHeight ; 

    // This is an arbitrary distance (in pixel) you can play with. 
    // It's the distance you wish to have between the bottom of the button and the bottom of the image. 
    // It may need more than 20 pixels. 
    var distanceFromImageBottom = 20; 

    // This is the new position to give to the button. 
    var newButtonPos = thisPos - imageAboveBottom - thisHeight - distanceFromImageBottom; 

    $(this).css({"position":"relative","top":newButtonPos}); 
}); 
+0

問題是,如果產品有多行標題,位置將會改變。 –

+0

我編輯過,看看;) –

+0

非常感謝你,但不幸的是,如果產品標題在多行上,它仍然會給出不同的位置。 –

相關問題