html - 在缩略图图像顶部显示一个按钮

标签 html css twitter-bootstrap-3

我试图在缩略图图像的顶部放置一个按钮,但该按钮是在图像之后的标题区域中添加的。 这是代码:

<div class="thumbnail">
    <img class="img-responsive"alt="300x200" src="network_sec.jpg">
    <button class="btn btn-default btn-warning pull-right"><span class="glyphicon glyphicon-user"></span> 10</button>

    <div class="caption">
        <h3 align="center">Network Security</h3>
        <br>
        <p>
        <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-wrench"></span> Manage</button>
           <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-eye-open"></span> Preview</button>
            <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-pencil"></span> Edit Info</button>
        </p>   
    </div>
</div>

我正在尝试对齐图像右下角的按钮。关于如何实现预期结果的任何建议?

最佳答案

我会将图像和按钮放在新的 div 中,然后像这样使用相对定位和绝对定位。

HTML

<div class="thumbnail">
    <div id="thumb">
    <img class="img-responsive"alt="300x200" src="network_sec.jpg">
    <button class="btn btn-default btn-warning pull-right"><span class="glyphicon glyphicon-user"></span> 10</button>
     </div>  
    <div class="caption">
    <h3 align="center">Network Security</h3>
    <br>
   <p>

    <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-wrench"></span> Manage</button>
    <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-eye-open"></span> Preview</button>
    <button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-pencil"></span> Edit Info</button>
 </p>   

</div>
</div>

CSS

#thumb
{
    position: relative;
    width: 300px;
    height: 200px;
}

#thumb img
{
    z-index: 1;
    position: absolute;  
    width: 300px;
    height:200px;
    top: 0;
    left: 0;

}
#thumb button
{
    z-index: 5;
    position: absolute;
    bottom: 0;
    right: 0;
}

这是你的想法吗?

关于html - 在缩略图图像顶部显示一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24307605/

相关文章:

javascript - 为什么我的模态窗口在点击后没有关闭?

html - Safari 只显示全屏 div 的右半部分

html - Div 背景没有绘制整个 Div

jQuery 不适用于 Bootstrap 3 Modal dom 元素

html - 设置 Bootstrap 背景

javascript - 基于单选按钮显示/隐藏表单字段

html - 无法在前端看到图像,joomla 网站

css - 高度为 1 像素的列

javascript - 如何使用 Javascript 动态绘制网格框以捕捉到网格

html - 如何将保存按钮放在 div 上方