css - 使内部div显示在底部

标签 css

我制作了一个缩略图,希望有一个内部 div 来显示 div 中的一些内容。我希望内部 div 位于底部而不是顶部,知道如何更改它吗?谢谢

.img_container{
	height:150px;
	width:200px;
	cursor:pointer;
	border-radius:2px;
	background:#333
}
.img_container img{
	height:150px;
	width:200px;
	position:absolute;
	margin:0 auto;	
	z-index:-999999;
}
.cat_container{
	background: rgba(25, 25, 25, .5);
	color:#fff;
	padding:5px;
	clear:both;
}
<div class="thumbnail_container">
        <div class="thumbnail">
            <div class="img_container">
                <img src="" />
                <div class="cat_container">bottom</div>
            </div>         
 
        </div>         
            
   </div>

最佳答案

.img_container 一个 position:relative 然后使用 position:absolute.cat_container 定位在底部和 bottom:0

.img_container{
    height:150px;
    width:200px;
    cursor:pointer;
    border-radius:2px;
    background:#333;
    position:relative;
}
.cat_container{
    background: rgba(25, 25, 25, .5);
    color:#fff;
    clear:both;
    padding:5px 0;
    position:absolute;
    bottom:0;
    width:100%;
}

这是一个 demo .

关于css - 使内部div显示在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28872117/

相关文章:

php - 每个用户的动态 CSS

javascript - 如何存储/检索元素移动的最后位置?

javascript - 如何从嵌入式视频中获取缩略图?

html - 我怎样才能使这个 CSS 菜单居中?

html - jar 宽度:auto expand the div beyond screen width

html - 如何使用 CSS 仅选择列表中成对的第一张图片?

javascript - 如何修复 Slimmenu 多级子项超出屏幕的问题

jquery/css 访问下面 HTML 中的以下 anchor 标记

javascript - 需要让我的网站和码笔版一样

javascript - 根据内容动态增加 ng-grid 行高,无需额外的插件和 jquery