gpt4 book ai didi

html - 将按钮放在每个内容的底部

转载 作者:太空宇宙 更新时间:2023-11-04 04:49:20 25 4
gpt4 key购买 nike

我有这样的标记。

  <ul class="products">
<li class="product pro first">
<a href="#">
<span class="onsale">Sale!</span>
<img width="100" height="140" title="battlefield" alt="battlefield" class="attachment-shop_catalog wp-post-image" src="http://web-vassets.ea.com/Assets/Resources/Image/FeaturedGame/battlefield-bad-company-2-thumb.png?cb=1340391602">
<h3>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem</h3>
<span class="price"><span class="strike-through"><span class="striked-text"><span class="amount">$&nbsp;67.00</span></span></span> <ins><span class="amount">$&nbsp;23.00</span></ins></span>
</a>
<a class="add_to_cart_button button product_type_simple" data-product_id="185" rel="nofollow" href="#">Add to cart</a>
</li>

<li class="product pro first">
<a href="#">
<span class="onsale">Sale!</span>
<img width="100" height="140" title="battlefield" alt="battlefield" class="attachment-shop_catalog wp-post-image" src="http://web-vassets.ea.com/Assets/Resources/Image/FeaturedGame/battlefield-bad-company-2-thumb.png?cb=1340391602">
<h3>Battle Field</h3>
<span class="price"><span class="strike-through"><span class="striked-text"><span class="amount">$&nbsp;67.00</span></span></span> <ins><span class="amount">$&nbsp;23.00</span></ins></span>
</a>
<a class="add_to_cart_button button product_type_simple" data-product_id="185" rel="nofollow" href="#">Add to cart</a>
</li>

<li class="product pro first">
<a href="#">
<span class="onsale">Sale!</span>
<img width="100" height="140" title="battlefield" alt="battlefield" class="attachment-shop_catalog wp-post-image" src="http://web-vassets.ea.com/Assets/Resources/Image/FeaturedGame/battlefield-bad-company-2-thumb.png?cb=1340391602">
<h3>Battle Field</h3>
<span class="price"><span class="strike-through"><span class="striked-text"><span class="amount">$&nbsp;67.00</span></span></span> <ins><span class="amount">$&nbsp;23.00</span></ins></span>
</a>
<a class="add_to_cart_button button product_type_simple" data-product_id="185" rel="nofollow" href="#">Add to cart</a>
</li>
</ul>

可以在这里看到现场演示示例http://tinkerbin.com/7dnpFPL3 .您可以在一行中看到三列。在每一列的底部都有一个名为 Add To Cart 的按钮。现在,您可以在每一列中看到不同长度的内容。此内容长度将按钮推到底部。最后两列的内容较少,这就是按钮位于内容中间的原因。现在我想要像第一个内容一样,最后两个内容的按钮位置应该在每个内容 div 的底部。无论内容的长度如何,它都不会影响按钮的位置。该按钮应始终位于内容的底部。我不能给出内容的任何固定高度。因为每列的内容长度可能非常长。我无法更改标记以使用表而不是 ul 和 liul 和 li 的标记是强制​​性的。我可以在其中更改类名称或标记。那么有人可以告诉我如何将按钮放在内容的底部吗?任何帮助和建议都将不胜感激。

我想要这样的输出 enter image description here

最佳答案

我会使用 javascript 使包含元素标题的 h3 元素与最长的标题一样高。

fiddle :http://jsfiddle.net/633nc/

Javascript

    function makeElementsSameHeight(element){
$element = $(element);
// check if element exists
if (!$element.length){
return false;
}
// get number of elements
numberElements = $element.length;
lengthArray = [];
for (i=0;i<numberElements;i++){
//put height of each element into an array
lengthArray.push( $element.eq(i).height() );
}

// calculate maximum height
largestHeight = Math.max.apply(Math, lengthArray);
// apply maximum height to all elements
$element.css('min-height',largestHeight + 'px');;
}

makeElementsSameHeight('.product h3');

先生。外星人关于您的标记是一团糟的说法是正确的。在担心这种事情之前,你应该把它清理干净。

关于html - 将按钮放在每个内容的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13775627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com