twitter-bootstrap 在 div 的角落覆盖引导标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17981604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:47:42  来源:igfitidea点击:

Overlaying bootstrap label in corner of a div

htmlcsstwitter-bootstrap

提问by JPD

I'm trying to overlay a bootstrap label in the corner of a DIV.

我试图在 DIV 的角落覆盖一个引导标签。

I'd like to put the label in the top left of the div, like a overlay so part on the div and part off.

我想将标签放在 div 的左上角,就像覆盖一样,一部分在 div 上,一部分关闭。

Thanks

谢谢

     <div class="span4" style="border-bottom: none; border-top: 4px solid #28A197;">
           <h3>Quick Links</h3>
      <div class="row">
      <div class="span2">
<div class="quickbtn">
<p><a href="#wirelessnetworkinfo" data-toggle="modal"><img src="images/icons/wirelesssignal.png" /></p>
<p>Wireless Network Information</a></p>
</div>
<br />
<div class="quickbtn">
<p><a href="http://mail.google.com" target="_blank"><img src="images/icons/gmail.png" /></p>
<p>Gmail</a></p>
</div>
      </div>

      </div>
  <span class="label label-important">UPDATED</span>

</div>  

Heres the JSFiddle of the coding etc. with example label ready for placement and the CSS for the div in question (button)

这是编码等的 JSFiddle,示例标签已准备好放置,以及相关 div 的 CSS(按钮)

回答by Mooseman

Using position: relativeon .quickbtnand position: absoluteon .quickbtn .label, you can absolutely position the label inside .quickbtn.

使用position: relativeon.quickbtnposition: absoluteon .quickbtn .label,您可以绝对将标签定位在里面.quickbtn

Fiddle: http://jsfiddle.net/Pq6JL/1/

小提琴:http: //jsfiddle.net/Pq6JL/1/



由于您的帖子不清楚,我添加以下内容:

If you wanted the label to overhang outside of .quickbtn, set a negative topand leftfor the position of .label:

如果您希望标签悬在 之外.quickbtn,请为 的位置设置一个负数top和:left.label

.quickbtn .label {
    position:absolute;
    left: -4px;
    top: -3px
}

Fiddle: http://jsfiddle.net/Pq6JL/3/

小提琴:http: //jsfiddle.net/Pq6JL/3/