0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 09:52:29 +01:00

remove popoverarrows mixin, relegate code to tooltips and popvers since we only used them once each; this fixes the problem of broken tooltips in 2.1

This commit is contained in:
Mark Otto 2012-07-09 22:14:30 -07:00
parent f4877c2369
commit 64e87a85f5
8 changed files with 275 additions and 263 deletions

View File

@ -4603,91 +4603,19 @@ input[type="submit"].btn.btn-mini {
} }
.tooltip.top { .tooltip.top {
margin-top: -2px; margin-top: -3px;
} }
.tooltip.right { .tooltip.right {
margin-left: 2px; margin-left: 3px;
} }
.tooltip.bottom { .tooltip.bottom {
margin-top: 2px; margin-top: 3px;
} }
.tooltip.left { .tooltip.left {
margin-left: -2px; margin-left: -3px;
}
.tooltip.top .tooltip-arrow {
bottom: -10px;
left: 50%;
margin-left: -10px;
border-top: 10px solid #cccccc;
border-top: 10px solid rgba(0, 0, 0, 0.2);
border-right: 10px solid transparent;
border-left: 10px solid transparent;
}
.tooltip.top .tooltip-arrow:after {
bottom: 1px;
left: -9px;
border-top: 9px solid #ffffff;
border-right: 9px solid transparent;
border-left: 9px solid transparent;
}
.tooltip.left .tooltip-arrow {
top: 50%;
right: -10px;
margin-top: -10px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid #cccccc;
border-left: 10px solid rgba(0, 0, 0, 0.2);
}
.tooltip.left .tooltip-arrow:after {
right: 1px;
bottom: -9px;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #ffffff;
}
.tooltip.bottom .tooltip-arrow {
top: -10px;
left: 50%;
margin-left: -10px;
border-right: 10px solid transparent;
border-bottom: 10px solid #cccccc;
border-bottom: 10px solid rgba(0, 0, 0, 0.2);
border-left: 10px solid transparent;
}
.tooltip.bottom .tooltip-arrow:after {
top: 1px;
left: -9px;
border-right: 9px solid transparent;
border-bottom: 9px solid #f5f5f5;
border-left: 9px solid transparent;
}
.tooltip.right .tooltip-arrow {
top: 50%;
left: -10px;
margin-top: -10px;
border-top: 10px solid transparent;
border-right: 10px solid #cccccc;
border-right: 10px solid rgba(0, 0, 0, 0.2);
border-bottom: 10px solid transparent;
}
.tooltip.right .tooltip-arrow:after {
bottom: -9px;
left: 1px;
border-top: 9px solid transparent;
border-right: 9px solid #ffffff;
border-bottom: 9px solid transparent;
} }
.tooltip-inner { .tooltip-inner {
@ -4706,6 +4634,40 @@ input[type="submit"].btn.btn-mini {
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
border-color: transparent;
border-style: solid;
}
.tooltip.top .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -5px;
border-top-color: #000000;
border-width: 5px 5px 0;
}
.tooltip.right .tooltip-arrow {
top: 50%;
left: 0;
margin-top: -5px;
border-right-color: #000000;
border-width: 5px 5px 5px 0;
}
.tooltip.left .tooltip-arrow {
top: 50%;
right: 0;
margin-top: -5px;
border-left-color: #000000;
border-width: 5px 0 5px 5px;
}
.tooltip.bottom .tooltip-arrow {
top: 0;
left: 50%;
margin-left: -5px;
border-bottom-color: #000000;
border-width: 0 5px 5px;
} }
.popover { .popover {
@ -4745,92 +4707,6 @@ input[type="submit"].btn.btn-mini {
margin-right: 10px; margin-right: 10px;
} }
.popover.top .arrow {
bottom: -10px;
left: 50%;
margin-left: -10px;
border-top: 10px solid #cccccc;
border-top: 10px solid rgba(0, 0, 0, 0.2);
border-right: 10px solid transparent;
border-left: 10px solid transparent;
}
.popover.top .arrow:after {
bottom: 1px;
left: -9px;
border-top: 9px solid #ffffff;
border-right: 9px solid transparent;
border-left: 9px solid transparent;
}
.popover.right .arrow {
top: 50%;
left: -10px;
margin-top: -10px;
border-top: 10px solid transparent;
border-right: 10px solid #cccccc;
border-right: 10px solid rgba(0, 0, 0, 0.2);
border-bottom: 10px solid transparent;
}
.popover.right .arrow:after {
bottom: -9px;
left: 1px;
border-top: 9px solid transparent;
border-right: 9px solid #ffffff;
border-bottom: 9px solid transparent;
}
.popover.bottom .arrow {
top: -10px;
left: 50%;
margin-left: -10px;
border-right: 10px solid transparent;
border-bottom: 10px solid #cccccc;
border-bottom: 10px solid rgba(0, 0, 0, 0.2);
border-left: 10px solid transparent;
}
.popover.bottom .arrow:after {
top: 1px;
left: -9px;
border-right: 9px solid transparent;
border-bottom: 9px solid #f5f5f5;
border-left: 9px solid transparent;
}
.popover.left .arrow {
top: 50%;
right: -10px;
margin-top: -10px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid #cccccc;
border-left: 10px solid rgba(0, 0, 0, 0.2);
}
.popover.left .arrow:after {
right: 1px;
bottom: -9px;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 9px solid #ffffff;
}
.popover .arrow {
position: absolute;
width: 0;
height: 0;
}
.popover .arrow:after {
position: absolute;
display: inline-block;
width: 0;
height: 0;
content: "";
}
.popover-title { .popover-title {
padding: 8px 14px; padding: 8px 14px;
margin: 0; margin: 0;
@ -4838,7 +4714,7 @@ input[type="submit"].btn.btn-mini {
font-weight: normal; font-weight: normal;
line-height: 18px; line-height: 18px;
background-color: #f5f5f5; background-color: #f5f5f5;
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid #dcdcdc;
-webkit-border-radius: 5px 5px 0 0; -webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0; -moz-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0;
@ -4854,6 +4730,81 @@ input[type="submit"].btn.btn-mini {
margin-bottom: 0; margin-bottom: 0;
} }
.popover .arrow,
.popover .arrow:after {
position: absolute;
display: inline-block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.popover .arrow:after {
z-index: -1;
content: "";
}
.popover.top .arrow {
bottom: -10px;
left: 50%;
margin-left: -10px;
border-top-color: #ffffff;
border-width: 10px 10px 0;
}
.popover.top .arrow:after {
bottom: -1px;
left: -11px;
border-top-color: rgba(0, 0, 0, 0.2);
border-width: 11px 11px 0;
}
.popover.right .arrow {
top: 50%;
left: -10px;
margin-top: -10px;
border-right-color: #ffffff;
border-width: 10px 10px 10px 0;
}
.popover.right .arrow:after {
bottom: -11px;
left: -1px;
border-right-color: rgba(0, 0, 0, 0.2);
border-width: 11px 11px 11px 0;
}
.popover.bottom .arrow {
top: -10px;
left: 50%;
margin-left: -10px;
border-bottom-color: #f5f5f5;
border-width: 0 10px 10px;
}
.popover.bottom .arrow:after {
top: -1px;
left: -11px;
border-bottom-color: rgba(0, 0, 0, 0.2);
border-width: 0 11px 11px;
}
.popover.left .arrow {
top: 50%;
right: -10px;
margin-top: -10px;
border-left-color: #ffffff;
border-width: 10px 0 10px 10px;
}
.popover.left .arrow:after {
right: -1px;
bottom: -11px;
border-left-color: rgba(0, 0, 0, 0.2);
border-width: 11px 0 11px 11px;
}
.thumbnails { .thumbnails {
margin-left: -20px; margin-left: -20px;
list-style: none; list-style: none;

View File

@ -598,6 +598,17 @@ form.bs-docs-example {
line-height: 18px; line-height: 18px;
} }
/* Tooltips */
.bs-docs-tooltip-examples {
text-align: center;
margin: 0 0 10px;
list-style: none;
}
.bs-docs-tooltip-examples li {
display: inline;
padding: 0 10px;
}
/* Popovers */ /* Popovers */
.bs-docs-example-popover { .bs-docs-example-popover {
padding-bottom: 24px; padding-bottom: 24px;

View File

@ -753,10 +753,20 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<p>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.</p> <p>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.</p>
<p>Hover over the links below to see tooltips:</p> <p>Hover over the links below to see tooltips:</p>
<div class="bs-docs-example tooltip-demo"> <div class="bs-docs-example tooltip-demo">
<p class="muted" style="margin-bottom: 0;">Tight pants next level keffiyeh <a href="#" rel="tooltip" title="first tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" rel="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" rel="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" rel="tooltip" title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral. <p class="muted" style="margin-bottom: 0;">Tight pants next level keffiyeh <a href="#" rel="tooltip" title="Default tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" rel="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" rel="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" rel="tooltip" title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral.
</p> </p>
</div> </div>
<h3>Four directions</h3>
<div class="bs-docs-example tooltip-demo">
<ul class="bs-docs-tooltip-examples">
<li><a href="#" rel="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</a></li>
<li><a href="#" rel="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</a></li>
<li><a href="#" rel="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</a></li>
<li><a href="#" rel="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</a></li>
</ul>
</div>
<hr class="bs-docs-separator"> <hr class="bs-docs-separator">

View File

@ -685,10 +685,20 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<p>{{_i}}Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.{{/i}}</p> <p>{{_i}}Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.{{/i}}</p>
<p>{{_i}}Hover over the links below to see tooltips:{{/i}}</p> <p>{{_i}}Hover over the links below to see tooltips:{{/i}}</p>
<div class="bs-docs-example tooltip-demo"> <div class="bs-docs-example tooltip-demo">
<p class="muted" style="margin-bottom: 0;">{{_i}}Tight pants next level keffiyeh <a href="#" rel="tooltip" title="first tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" rel="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" rel="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" rel="tooltip" title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral.{{/i}} <p class="muted" style="margin-bottom: 0;">{{_i}}Tight pants next level keffiyeh <a href="#" rel="tooltip" title="Default tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" rel="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" rel="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" rel="tooltip" title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral.{{/i}}
</p> </p>
</div>{{! /example }} </div>{{! /example }}
<h3>{{_i}}Four directions{{/i}}</h3>
<div class="bs-docs-example tooltip-demo">
<ul class="bs-docs-tooltip-examples">
<li><a href="#" rel="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</a></li>
<li><a href="#" rel="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</a></li>
<li><a href="#" rel="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</a></li>
<li><a href="#" rel="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</a></li>
</ul>
</div>{{! /example }}
<hr class="bs-docs-separator"> <hr class="bs-docs-separator">

View File

@ -508,75 +508,7 @@
margin-top: (@navbarHeight - @elementHeight) / 2; margin-top: (@navbarHeight - @elementHeight) / 2;
} }
// Popover arrows
// -------------------------
// For tipsies and popovers
#popoverArrow {
.top(@arrowWidth: 10px, @color: rgba(0,0,0,.2)) {
bottom: -@arrowWidth;
left: 50%;
margin-left: -@arrowWidth;
border-left: @arrowWidth solid transparent;
border-right: @arrowWidth solid transparent;
border-top: @arrowWidth solid #ccc;
border-top: @arrowWidth solid @color;
&:after {
border-left: @arrowWidth - 1 solid transparent;
border-right: @arrowWidth - 1 solid transparent;
border-top: @arrowWidth - 1 solid #fff;
bottom: 1px;
left: -@arrowWidth + 1;
}
}
.right(@arrowWidth: 10px, @color: rgba(0,0,0,.2)) {
top: 50%;
left: -@arrowWidth;
margin-top: -@arrowWidth;
border-top: @arrowWidth solid transparent;
border-bottom: @arrowWidth solid transparent;
border-right: @arrowWidth solid #ccc;
border-right: @arrowWidth solid @color;
&:after {
border-top: @arrowWidth - 1 solid transparent;
border-bottom: @arrowWidth - 1 solid transparent;
border-right: @arrowWidth - 1 solid #fff;
bottom: -@arrowWidth + 1;
left: 1px;
}
}
.bottom(@arrowWidth: 10px, @color: rgba(0,0,0,.2)) {
top: -@arrowWidth;
left: 50%;
margin-left: -@arrowWidth;
border-left: @arrowWidth solid transparent;
border-right: @arrowWidth solid transparent;
border-bottom: @arrowWidth solid #ccc;
border-bottom: @arrowWidth solid @color;
&:after {
border-left: @arrowWidth - 1 solid transparent;
border-right: @arrowWidth - 1 solid transparent;
border-bottom: @arrowWidth - 1 solid #f5f5f5;
top: 1px;
left: -@arrowWidth + 1;
}
}
.left(@arrowWidth: 10px, @color: rgba(0,0,0,.2)) {
top: 50%;
right: -@arrowWidth;
margin-top: -@arrowWidth;
border-top: @arrowWidth solid transparent;
border-bottom: @arrowWidth solid transparent;
border-left: @arrowWidth solid #ccc;
border-left: @arrowWidth solid @color;
&:after {
border-top: @arrowWidth - 1 solid transparent;
border-bottom: @arrowWidth - 1 solid transparent;
border-left: @arrowWidth - 1 solid #fff;
bottom: -@arrowWidth + 1;
right: 1px;
}
}
}
// Grid System // Grid System
// ----------- // -----------

View File

@ -25,25 +25,6 @@
&.bottom { margin-top: 10px; } &.bottom { margin-top: 10px; }
&.left { margin-right: 10px; } &.left { margin-right: 10px; }
// Call the mixin for the arrows
&.top .arrow { #popoverArrow > .top(); }
&.right .arrow { #popoverArrow > .right(); }
&.bottom .arrow { #popoverArrow > .bottom(); }
&.left .arrow { #popoverArrow > .left(); }
// Common arrow styles
.arrow {
position: absolute;
width: 0;
height: 0;
&:after {
position: absolute;
display: inline-block;
width: 0;
height: 0;
content: "";
}
}
} }
.popover-title { .popover-title {
@ -52,8 +33,8 @@
font-size: 14px; font-size: 14px;
font-weight: normal; font-weight: normal;
line-height: 18px; line-height: 18px;
background-color: #f5f5f5; background-color: @popoverTitleBackground;
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid darken(@popoverTitleBackground, 10%);
.border-radius(5px 5px 0 0); .border-radius(5px 5px 0 0);
} }
@ -63,3 +44,73 @@
margin-bottom: 0; margin-bottom: 0;
} }
} }
// Arrows
.popover .arrow,
.popover .arrow:after {
position: absolute;
display: inline-block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.popover .arrow:after {
content: "";
z-index: -1;
}
.popover {
&.top .arrow {
bottom: -@popoverArrowWidth;
left: 50%;
margin-left: -@popoverArrowWidth;
border-width: @popoverArrowWidth @popoverArrowWidth 0;
border-top-color: @popoverArrowColor;
&:after {
border-width: @popoverArrowOuterWidth @popoverArrowOuterWidth 0;
border-top-color: @popoverArrowOuterColor;
bottom: -1px;
left: -@popoverArrowOuterWidth;
}
}
&.right .arrow {
top: 50%;
left: -@popoverArrowWidth;
margin-top: -@popoverArrowWidth;
border-width: @popoverArrowWidth @popoverArrowWidth @popoverArrowWidth 0;
border-right-color: @popoverArrowColor;
&:after {
border-width: @popoverArrowOuterWidth @popoverArrowOuterWidth @popoverArrowOuterWidth 0;
border-right-color: @popoverArrowOuterColor;
bottom: -@popoverArrowOuterWidth;
left: -1px;
}
}
&.bottom .arrow {
top: -@popoverArrowWidth;
left: 50%;
margin-left: -@popoverArrowWidth;
border-width: 0 @popoverArrowWidth @popoverArrowWidth;
border-bottom-color: @popoverTitleBackground;
&:after {
border-width: 0 @popoverArrowOuterWidth @popoverArrowOuterWidth;
border-bottom-color: @popoverArrowOuterColor;
top: -1px;
left: -@popoverArrowOuterWidth;
}
}
&.left .arrow {
top: 50%;
right: -@popoverArrowWidth;
margin-top: -@popoverArrowWidth;
border-width: @popoverArrowWidth 0 @popoverArrowWidth @popoverArrowWidth;
border-left-color: @popoverArrowColor;
&:after {
border-width: @popoverArrowOuterWidth 0 @popoverArrowOuterWidth @popoverArrowOuterWidth;
border-left-color: @popoverArrowOuterColor;
bottom: -@popoverArrowOuterWidth;
right: -1px;
}
}
}

View File

@ -3,6 +3,7 @@
// -------------------------------------------------- // --------------------------------------------------
// Base class
.tooltip { .tooltip {
position: absolute; position: absolute;
z-index: @zindexTooltip; z-index: @zindexTooltip;
@ -12,15 +13,13 @@
font-size: 11px; font-size: 11px;
.opacity(0); .opacity(0);
&.in { .opacity(80); } &.in { .opacity(80); }
&.top { margin-top: -2px; } &.top { margin-top: -3px; }
&.right { margin-left: 2px; } &.right { margin-left: 3px; }
&.bottom { margin-top: 2px; } &.bottom { margin-top: 3px; }
&.left { margin-left: -2px; } &.left { margin-left: -3px; }
&.top .tooltip-arrow { #popoverArrow > .top(); }
&.left .tooltip-arrow { #popoverArrow > .left(); }
&.bottom .tooltip-arrow { #popoverArrow > .bottom(); }
&.right .tooltip-arrow { #popoverArrow > .right(); }
} }
// Wrapper for the tooltip content
.tooltip-inner { .tooltip-inner {
max-width: 200px; max-width: 200px;
padding: 3px 8px; padding: 3px 8px;
@ -30,8 +29,42 @@
background-color: @black; background-color: @black;
.border-radius(4px); .border-radius(4px);
} }
// Arrows
.tooltip-arrow { .tooltip-arrow {
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
border-color: transparent;
border-style: solid;
}
.tooltip {
&.top .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -@tooltipArrowWidth;
border-width: @tooltipArrowWidth @tooltipArrowWidth 0;
border-top-color: @tooltipArrowColor;
}
&.right .tooltip-arrow {
top: 50%;
left: 0;
margin-top: -@tooltipArrowWidth;
border-width: @tooltipArrowWidth @tooltipArrowWidth @tooltipArrowWidth 0;
border-right-color: @tooltipArrowColor;
}
&.left .tooltip-arrow {
top: 50%;
right: 0;
margin-top: -@tooltipArrowWidth;
border-width: @tooltipArrowWidth 0 @tooltipArrowWidth @tooltipArrowWidth;
border-left-color: @tooltipArrowColor;
}
&.bottom .tooltip-arrow {
top: 0;
left: 50%;
margin-left: -@tooltipArrowWidth;
border-width: 0 @tooltipArrowWidth @tooltipArrowWidth;
border-bottom-color: @tooltipArrowColor;
}
} }

View File

@ -198,6 +198,20 @@
@infoBorder: darken(spin(@infoBackground, -10), 7%); @infoBorder: darken(spin(@infoBackground, -10), 7%);
// Tooltips and popovers
// -------------------------
@tooltipArrowWidth: 5px;
@tooltipArrowColor: #000;
@popoverArrowWidth: 10px;
@popoverArrowColor: #fff;
@popoverTitleBackground: #f5f5f5;
// Special enhancement for popovers
@popoverArrowOuterWidth: @popoverArrowWidth + 1;
@popoverArrowOuterColor: rgba(0,0,0,.2);
// GRID // GRID
// -------------------------------------------------- // --------------------------------------------------