简体   繁体   English

在文档的右上角显示文本?

[英]Show text in the top-right corner, like in docs?

The new twitter-bootstrap docs have a nice interface for delimiting examples. 新的twitter-bootstrap文档具有一个很好的界面,可以用来分隔示例。

镜头

How do I get this same effect, but within the well ? well如何获得相同的效果?

My attempt: http://jsfiddle.net/YdusM/ 我的尝试: http : //jsfiddle.net/YdusM/

How about that: jsFiddle 怎么样: jsFiddle

Apply .well:before {...} instead .corner_text:before {...} 应用.well:before {...}代替.corner_text:before {...}

UPDATE: 更新:

Apply 'example element' for specific well-block: jsFiddle 为特定的井应用“示例元素”: jsFiddle

You can just inspect the code in the docs, and you wil find this css, applied to the exmaple wrapper: 您只需要检查文档中的代码,就会发现将这个CSS应用于exmaple包装器:

.bs-docs-example::after {
content: "Example";
position: absolute;
top: -1px;
left: -1px;
padding: 3px 7px;
font-size: 12px;
font-weight: bold;
background-color: whiteSmoke;
border: 1px solid #DDD;
color: #9DA0A4;
-webkit-border-radius: 4px 0 4px 0;
-moz-border-radius: 4px 0 4px 0;
border-radius: 4px 0 4px 0;
}

Add something similar as a custom class to your css, or you could even do it in less to use the bootstrap variables and mixins. 在您的CSS中添加类似于自定义类的内容,或者甚至可以花更少的时间来使用bootstrap变量和mixins。 If you want the text to be addaptable, it would perhaps be better to forget about the :after and adapt this styling a bit to apply it to a specific element holding the text you want and place it inside the wrapper. 如果您希望文本是可扩展的,则最好不要考虑:after,并对此样式进行一些调整,以将其应用于包含所需文本的特定元素,然后将其放置在包装器中。

edit: 编辑:
For the positioning to work, you should set the wrapper to position: relative; 为了使定位有效,您应该将包装器设置为position: relative; as well. 也一样 Not sure what you are after, but i updated your fiddle to demonstrate: http://jsfiddle.net/YdusM/9/ 不确定您要做什么,但我更新了您的小提琴以进行演示: http : //jsfiddle.net/YdusM/9/

Instead of applying :before to outer div. 而不是将:before应用于外部div。 I made it to .well and adjusted the padding top and left to -20px .. 我将其设置为.well ,并将顶部和左侧的填充调整为-20px ..

ie

.well:before {
  position: relative;
  content: "Example";
  top: -20px;
  left: -20px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: bold;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  color: #9da0a4;
  -webkit-border-radius: 4px 0 4px 0;
     -moz-border-radius: 4px 0 4px 0;
          border-radius: 4px 0 4px 0;
}

Check the fiddle http://jsfiddle.net/YdusM/7/ 检查小提琴http://jsfiddle.net/YdusM/7/

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

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