简体   繁体   English

在缩略图上方显示一个按钮

[英]Displaying a button on top of thumbnail image

I'm trying to place a button on top of a thumbnail image but the button is added after the image, in the caption area. 我试图在缩略图上方放置一个按钮,但该按钮在图像后的标题区域中添加。 Here is the code: 这是代码:

<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>

I'm trying to align the button at the bottom right part of the image. 我正在尝试将按钮对准图像的右下角。 Any suggestions on how can I achieve the desired result? 关于如何获得预期结果的任何建议?

I would put the image an the button in a new div, then use positioning relative and absolute like this. 我将图像放在新div中的按钮上,然后像这样使用相对和绝对定位。

HTML 的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 的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;
}

Is that what you had in mind? 那是你的想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM