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

fixes #9310: alerts aren't dismissable by default, now requires .alert-dismissable if you need a close button

This commit is contained in:
Mark Otto 2013-08-12 01:20:22 -07:00
parent aefed0ada9
commit 6dbf588237
5 changed files with 56 additions and 35 deletions

View File

@ -94,6 +94,7 @@
<ul class="nav"> <ul class="nav">
<li><a href="#alerts-default">Default alert</a></li> <li><a href="#alerts-default">Default alert</a></li>
<li><a href="#alerts-alternatives">Contextual alternatives</a></li> <li><a href="#alerts-alternatives">Contextual alternatives</a></li>
<li><a href="#alerts-dismissable">Dismissable alerts</a></li>
<li><a href="#alerts-links">Links in alerts</a></li> <li><a href="#alerts-links">Links in alerts</a></li>
</ul> </ul>
</li> </li>

View File

@ -1880,40 +1880,30 @@ body { padding-bottom: 70px; }
</div> </div>
<p class="lead">Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the <a href="../javascript/#js-alerts">alerts jQuery plugin</a>.</p> <p class="lead">Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the <a href="../javascript/#js-alerts">alerts jQuery plugin</a>.</p>
<h3 id="alerts-default">Default alert</h3> <h2 id="alerts-default">Default alert</h2>
<p>Wrap any text and an optional dismiss button in <code>.alert</code> for a basic warning alert message.</p> <p>Wrap any text and an optional dismiss button in <code>.alert</code> for a basic warning alert message.</p>
<div class="bs-callout bs-callout-warning">
<h4>Ensure proper behavior across all devices</h4>
<p>Be sure to use the <code>&lt;button&gt;</code> element with the <code>data-dismiss="alert"</code> data attribute.</p>
</div>
<div class="bs-example"> <div class="bs-example">
<div class="alert"> <div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> Best check yo self, you're not looking too good. <strong>Warning!</strong> Best check yo self, you're not looking too good.
</div> </div>
</div> </div>
{% highlight html %} {% highlight html %}
<div class="alert"> <div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> Best check yo self, you're not looking too good. <strong>Warning!</strong> Best check yo self, you're not looking too good.
</div> </div>
{% endhighlight %} {% endhighlight %}
<h3 id="alerts-alternatives">Contextual alternatives</h3> <h2 id="alerts-alternatives">Contextual alternatives</h2>
<p>Add optional classes to change an alert's connotation.</p> <p>Add optional classes to change an alert's connotation.</p>
<div class="bs-example"> <div class="bs-example">
<div class="alert alert-danger"> <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Oh snap!</strong> Change a few things up and try submitting again. <strong>Oh snap!</strong> Change a few things up and try submitting again.
</div> </div>
<div class="alert alert-success"> <div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Well done!</strong> You successfully read this important alert message. <strong>Well done!</strong> You successfully read this important alert message.
</div> </div>
<div class="alert alert-info"> <div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Heads up!</strong> This alert needs your attention, but it's not super important. <strong>Heads up!</strong> This alert needs your attention, but it's not super important.
</div> </div>
</div> </div>
@ -1923,19 +1913,36 @@ body { padding-bottom: 70px; }
<div class="alert alert-info">...</div> <div class="alert alert-info">...</div>
{% endhighlight %} {% endhighlight %}
<h3 id="alerts-links">Links in alerts</h3> <h2 id="alerts-dismissable">Dismissable alerts</h2>
<p>Build on any alert by adding an optional <code>.alert-dismissable</code> and close button.</p>
<div class="bs-example">
<div class="alert alert-dismissable">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
</div>
{% highlight html %}
<div class="alert alert-dismissable">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
{% endhighlight %}
<div class="bs-callout bs-callout-warning">
<h4>Ensure proper behavior across all devices</h4>
<p>Be sure to use the <code>&lt;button&gt;</code> element with the <code>data-dismiss="alert"</code> data attribute.</p>
</div>
<h2 id="alerts-links">Links in alerts</h2>
<p>Use the <code>.alert-link</code> utility class to quickly provide matching colored links within any alert.</p> <p>Use the <code>.alert-link</code> utility class to quickly provide matching colored links within any alert.</p>
<div class="bs-example"> <div class="bs-example">
<div class="alert alert-danger"> <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Oh snap!</strong> <a href="#" class="alert-link">Change a few things up</a> and try submitting again. <strong>Oh snap!</strong> <a href="#" class="alert-link">Change a few things up</a> and try submitting again.
</div> </div>
<div class="alert alert-success"> <div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Well done!</strong> You successfully read <a href="#" class="alert-link">this important alert message</a>. <strong>Well done!</strong> You successfully read <a href="#" class="alert-link">this important alert message</a>.
</div> </div>
<div class="alert alert-info"> <div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Heads up!</strong> This <a href="#" class="alert-link">alert needs your attention</a>, but it's not super important. <strong>Heads up!</strong> This <a href="#" class="alert-link">alert needs your attention</a>, but it's not super important.
</div> </div>
</div> </div>

View File

@ -4117,7 +4117,7 @@ button.close {
} }
.alert { .alert {
padding: 15px 35px 15px 15px; padding: 15px;
margin-bottom: 20px; margin-bottom: 20px;
color: #c09853; color: #c09853;
background-color: #fcf8e3; background-color: #fcf8e3;
@ -4139,13 +4139,6 @@ button.close {
color: #a47e3c; color: #a47e3c;
} }
.alert .close {
position: relative;
top: -2px;
right: -21px;
color: inherit;
}
.alert > p, .alert > p,
.alert > ul { .alert > ul {
margin-bottom: 0; margin-bottom: 0;
@ -4155,6 +4148,17 @@ button.close {
margin-top: 5px; margin-top: 5px;
} }
.alert-dismissable {
padding-right: 35px;
}
.alert-dismissable .close {
position: relative;
top: -2px;
right: -21px;
color: inherit;
}
.alert-success { .alert-success {
color: #468847; color: #468847;
background-color: #dff0d8; background-color: #dff0d8;

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
// ------------------------- // -------------------------
.alert { .alert {
padding: @alert-padding (@alert-padding + 20) @alert-padding @alert-padding; padding: @alert-padding;
margin-bottom: @line-height-computed; margin-bottom: @line-height-computed;
color: @alert-text; color: @alert-text;
background-color: @alert-bg; background-color: @alert-bg;
@ -30,14 +30,6 @@
color: darken(@alert-text, 10%); color: darken(@alert-text, 10%);
} }
// Adjust close link position
.close {
position: relative;
top: -2px;
right: -21px;
color: inherit;
}
// Improve alignment and spacing of inner content // Improve alignment and spacing of inner content
> p, > p,
> ul { > ul {
@ -48,8 +40,25 @@
} }
} }
// Dismissable alerts
//
// Expand the right padding and account for the close button's positioning.
.alert-dismissable {
padding-right: (@alert-padding + 20);
// Adjust close link position
.close {
position: relative;
top: -2px;
right: -21px;
color: inherit;
}
}
// Alternate styles // Alternate styles
// ------------------------- //
// Generate contextual modifier classes for colorizing the alert.
.alert-success { .alert-success {
.alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text); .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text);