html - 对齐到一里的底部?

标签 html css html-lists

我想在没有 javascript 的情况下执行此操作。

我不知道如何让所有类为“item”的 li 与 div#recent 的底部对齐。基本上,每里都是 192px 宽。问题是每张产品图片的高度都不同,所以如果一张只有 40 像素高,则文本与旁边的图片的位置不同。

<div id="recent">
<h2>Recent Items</h2>
<ul>
    <li class="item">
        <img src="images/product1.png" />
        <a href="#">
            Product Name Here<br/>
            Brand Name Here
        </a>
        <p>$182.32</p>
    </li>
</ul>
</div>

有什么想法吗?

最佳答案

将您的图像包裹在自己的容器中(就像另一个 div)并为该容器指定特定高度。

<div id="recent"> 
<h2>Recent Items</h2> 
<ul> 
    <li class="item"> 
        <div class = "img_wrapper"><img src="images/product1.png" /></div>
        <a href="#"> 
            Product Name Here<br/> 
            Brand Name Here 
        </a> 
        <p>$182.32</p> 
    </li> 
</ul> 
</div> 

在你的 css 中,给 .img_wrapper 一个 50px 或其他的高度。

关于html - 对齐到一里的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2686498/

相关文章:

javascript - Bootstrap Datepicker 显示在 popover 后面

css - Safari 媒体查询问题的响应式设计

html - 并排放置 ul li 内容

html - 内联 block 与内联似乎不共享相同的基线

javascript - 使用 AJAX 附加 DIV 内容 - 上一个/下一个

html - ul 正在应用样式,但从哪里应用?

html - 在html中的ol中的数字前插入一个元素

javascript - 将 javascript 变量的值附加到不带脚本的标签

html - HTML 或 LaTeX 的 gettext?

html - 在CSS垂直菜单中添加间距