As you can see from my screenshot I am trying to align the Add to card buttons horizontally. I have narrowed down the file to “New_grid.phtml” but im not sure where to start in terms of actually aligning them!
I believe this is the div that needs aligning which is within “new_grid.phtml”
<div class="product-item-actions">
<?php if ($showCart): ?>
<div class="actions-primary">
<?php if ($_item->isSaleable()): ?>
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
<button class="action tocart primary"
data-mage-init='{"redirectUrl":{"url":"<?= /* @escapeNotVerified */ $block->getAddToCartUrl($_item) ?>"}}'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php else: ?>
<?php
$postDataHelper = $this->helper('MagentoFrameworkDataHelperPostHelper');
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
?>
<button class="action tocart primary"
data-post='<?= /* @escapeNotVerified */ $postData ?>'
type="button" title="<?= /* @escapeNotVerified */ __('Add to Cart') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
</button>
<?php endif; ?>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<div class="stock available"><span><?= /* @escapeNotVerified */ __('In stock') ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= /* @escapeNotVerified */ __('Out of stock') ?></span></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($showWishlist || $showCompare): ?>
<div class="actions-secondary" data-role="add-to-links">
<?php if ($this->helper('MagentoWishlistHelperData')->isAllow() && $showWishlist): ?>
<a href="#"
data-post='<?= /* @escapeNotVerified */ $block->getAddToWishlistParams($_item) ?>'
class="action towishlist" data-action="add-to-wishlist"
title="<?= /* @escapeNotVerified */ __('Add to Wish List') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Wish List') ?></span>
</a>
<?php endif; ?>
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
<?php $compareHelper = $this->helper('MagentoCatalogHelperProductCompare');?>
<a href="#" class="action tocompare"
data-post='<?= /* @escapeNotVerified */ $compareHelper->getPostDataParams($_item) ?>'
title="<?= /* @escapeNotVerified */ __('Add to Compare') ?>">
<span><?= /* @escapeNotVerified */ __('Add to Compare') ?></span>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
4
Answers
I ended up making the block that holds the text have a minimum height this solved the issues as long as our title dont get too long! This was added to new_grid.phtml
Hope in your case the complete name of product showing is not mandatory if it is lengthy., If so, you can make the name as shorten by using three dot css..And your alignment will be fine..please try to implement this too..And it will also help you to get hit for your product detail page and the other related products..
Three dot css :
Use your name class instead id here
Just change the width as of your need..
If showing entire name is mandatory, then give min height for your name area too..Hope this will help. The first one is recommended..
If you don’t want to cut the name of the product, you can use
flexbox
. There is a complete mixin inside_utilities.less
within Magento lib/ folder that you can reuse on your theme styles.With that tool, the elements will get the height of the tallest for each row. No need to set a
min-height
which is not the best case scenario for a Responsive fluid website.Check this: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
You should use
If you don’t want break the responsive