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

refactor buttons.less

This commit is contained in:
Mark Otto 2012-01-30 20:50:51 -08:00
parent 155047c3e6
commit 21bebe77fe
6 changed files with 470 additions and 459 deletions

Binary file not shown.

View File

@ -1653,6 +1653,92 @@ table .span12 {
filter: alpha(opacity=40); filter: alpha(opacity=40);
cursor: pointer; cursor: pointer;
} }
.btn {
display: inline-block;
padding: 4px 10px 4px;
font-size: 13px;
line-height: 18px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
background-color: #fafafa;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), color-stop(25%, #ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: -moz-linear-gradient(top, #ffffff, #ffffff 25%, #e6e6e6);
background-image: -ms-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: -o-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);
border: 1px solid #ccc;
border-bottom-color: #bbb;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
cursor: pointer;
*margin-left: .3em;
}
.btn:first-child {
*margin-left: 0;
}
.btn:hover {
color: #333333;
text-decoration: none;
background-color: #e6e6e6;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-ms-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
.btn:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn.active, .btn:active {
background-image: none;
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
background-color: #e6e6e6;
background-color: #d9d9d9 \9;
color: rgba(0, 0, 0, 0.5);
outline: 0;
}
.btn.disabled, .btn[disabled] {
cursor: default;
background-image: none;
background-color: #e6e6e6;
opacity: 0.65;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.btn.large {
padding: 9px 14px;
font-size: 15px;
line-height: normal;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.btn.large .icon {
margin-top: 1px;
}
.btn.small {
padding: 5px 9px;
font-size: 11px;
line-height: 16px;
}
.btn.small .icon {
margin-top: -1px;
}
.btn.primary, .btn.primary,
.btn.primary:hover, .btn.primary:hover,
.btn.warning, .btn.warning,
@ -1793,92 +1879,6 @@ table .span12 {
.btn.info:active, .btn.info.active { .btn.info:active, .btn.info.active {
background-color: #24748c \9; background-color: #24748c \9;
} }
.btn {
display: inline-block;
padding: 4px 10px 4px;
font-size: 13px;
line-height: 18px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
background-color: #fafafa;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), color-stop(25%, #ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: -moz-linear-gradient(top, #ffffff, #ffffff 25%, #e6e6e6);
background-image: -ms-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: -o-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-image: linear-gradient(#ffffff, #ffffff 25%, #e6e6e6);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);
border: 1px solid #ccc;
border-bottom-color: #bbb;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
cursor: pointer;
*margin-left: .3em;
}
.btn:first-child {
*margin-left: 0;
}
.btn:hover {
color: #333333;
text-decoration: none;
background-color: #e6e6e6;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-ms-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
.btn:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn.active, .btn:active {
background-image: none;
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
background-color: #e6e6e6;
background-color: #d9d9d9 \9;
color: rgba(0, 0, 0, 0.5);
outline: 0;
}
.btn.disabled, .btn[disabled] {
cursor: default;
background-image: none;
background-color: #e6e6e6;
opacity: 0.65;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.btn.large {
padding: 9px 14px;
font-size: 15px;
line-height: normal;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.btn.large .icon {
margin-top: 1px;
}
.btn.small {
padding: 5px 9px;
font-size: 11px;
line-height: 16px;
}
.btn.small .icon {
margin-top: -1px;
}
button.btn, input[type="submit"].btn { button.btn, input[type="submit"].btn {
*padding-top: 2px; *padding-top: 2px;
*padding-bottom: 2px; *padding-bottom: 2px;

View File

@ -73,7 +73,7 @@ hr.soften {
line-height: 36px; line-height: 36px;
color: #333; color: #333;
} }
.jumbotron .btn-large { .jumbotron .btn {
font-size: 20px; font-size: 20px;
font-weight: normal; font-weight: normal;
padding: 14px 24px; padding: 14px 24px;

View File

@ -74,17 +74,15 @@
<div class="container"> <div class="container">
<div id="overview"> <!-- Masthead
================================================== -->
<!-- Masthead <header class="jumbotron masthead">
================================================== -->
<header class="jumbotron masthead">
<div class="inner"> <div class="inner">
<h1>Bootstrap, from Twitter</h1> <h1>Bootstrap, from Twitter</h1>
<p>Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.</p> <p>Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.</p>
<p class="download-info"> <p class="download-info">
<a href="https://github.com/twitter/bootstrap/" class="btn primary btn-large">View project on GitHub</a> <a href="https://github.com/twitter/bootstrap/" class="btn primary large">View project on GitHub</a>
<a href="assets/bootstrap.zip" class="btn btn-large">Download Bootstrap</a> <a href="assets/bootstrap.zip" class="btn large">Download Bootstrap</a>
</p> </p>
</div> </div>
@ -108,11 +106,11 @@
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li> </li>
</ul> </ul>
</header> </header>
<hr class="soften"> <hr class="soften">
<div class="marketing"> <div class="marketing">
<h1>Designed for everyone, everywhere.</h1> <h1>Designed for everyone, everywhere.</h1>
<p class="marketing-byline">Need reasons to love Bootstrap? Look no further.</p> <p class="marketing-byline">Need reasons to love Bootstrap? Look no further.</p>
<div class="row"> <div class="row">
@ -211,8 +209,7 @@
</li> </li>
</ul> </ul>
</div><!-- /.marketing --> </div><!-- /.marketing -->
</div><!-- /#overview -->
<!-- Footer <!-- Footer
================================================== --> ================================================== -->

View File

@ -1,14 +1,12 @@
<div id="overview"> <!-- Masthead
================================================== -->
<!-- Masthead <header class="jumbotron masthead">
================================================== -->
<header class="jumbotron masthead">
<div class="inner"> <div class="inner">
<h1>{{_i}}Bootstrap, from Twitter{{/i}}</h1> <h1>{{_i}}Bootstrap, from Twitter{{/i}}</h1>
<p>Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.</p> <p>Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.</p>
<p class="download-info"> <p class="download-info">
<a href="https://github.com/twitter/bootstrap/" class="btn primary btn-large">{{_i}}View project on GitHub{{/i}}</a> <a href="https://github.com/twitter/bootstrap/" class="btn primary large">{{_i}}View project on GitHub{{/i}}</a>
<a href="assets/bootstrap.zip" class="btn btn-large">{{_i}}Download Bootstrap{{/i}}</a> <a href="assets/bootstrap.zip" class="btn large">{{_i}}Download Bootstrap{{/i}}</a>
</p> </p>
</div> </div>
@ -32,11 +30,11 @@
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li> </li>
</ul> </ul>
</header> </header>
<hr class="soften"> <hr class="soften">
<div class="marketing"> <div class="marketing">
<h1>{{_i}}Designed for everyone, everywhere.{{/i}}</h1> <h1>{{_i}}Designed for everyone, everywhere.{{/i}}</h1>
<p class="marketing-byline">{{_i}}Need reasons to love Bootstrap? Look no further.{{/i}}</p> <p class="marketing-byline">{{_i}}Need reasons to love Bootstrap? Look no further.{{/i}}</p>
<div class="row"> <div class="row">
@ -135,5 +133,4 @@
</li> </li>
</ul> </ul>
</div><!-- /.marketing --> </div><!-- /.marketing -->
</div><!-- /#overview -->

View File

@ -2,57 +2,11 @@
// ------------- // -------------
// Colors
// ------
.btn {
// Set text color
&.primary,
&.primary:hover,
&.warning,
&.warning:hover,
&.danger,
&.danger:hover,
&.success,
&.success:hover,
&.info,
&.info:hover {
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
color: @white
}
&.primary.active,
&.warning.active,
&.danger.active,
&.success.active,
&.info.active {
color: rgba(255,255,255,.75);
}
&.primary {
.buttonBackground(@primaryButtonBackground, spin(@primaryButtonBackground, 20));
}
// Warning appears are orange
&.warning {
.buttonBackground(lighten(@orange, 15%), @orange);
}
// Danger and error appear as red
&.danger {
.buttonBackground(#ee5f5b, #bd362f);
}
// Success appears as green
&.success {
.buttonBackground(#62c462, #51a351);
}
// Info appears as a neutral blue
&.info {
.buttonBackground(#5bc0de, #2f96b4);
}
}
// Base styles // Base styles
// ----------- // --------------------------------------------------
// Core
.btn { .btn {
// Button Base
display: inline-block; display: inline-block;
padding: 4px 10px 4px; padding: 4px 10px 4px;
font-size: @baseFontSize; font-size: @baseFontSize;
@ -68,9 +22,12 @@
.box-shadow(@shadow); .box-shadow(@shadow);
cursor: pointer; cursor: pointer;
// Give IE7 some love
.ie7-restore-left-whitespace(); .ie7-restore-left-whitespace();
}
&:hover { // Hover state
.btn:hover {
color: @grayDark; color: @grayDark;
text-decoration: none; text-decoration: none;
background-color: darken(@white, 10%); background-color: darken(@white, 10%);
@ -79,16 +36,16 @@
// transition is only when going to hover, otherwise the background // transition is only when going to hover, otherwise the background
// behind the gradient (there for IE<=9 fallback) gets mismatched // behind the gradient (there for IE<=9 fallback) gets mismatched
.transition(background-position .1s linear); .transition(background-position .1s linear);
} }
// Focus state for keyboard and accessibility // Focus state for keyboard and accessibility
&:focus { .btn:focus {
.tab-focus(); .tab-focus();
} }
// Active and Disabled states // Active state
&.active, .btn.active,
&:active { .btn:active {
background-image: none; background-image: none;
@shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05); @shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
.box-shadow(@shadow); .box-shadow(@shadow);
@ -96,37 +53,97 @@
background-color: darken(@white, 15%) e("\9"); background-color: darken(@white, 15%) e("\9");
color: rgba(0,0,0,.5); color: rgba(0,0,0,.5);
outline: 0; outline: 0;
} }
&.disabled,
&[disabled] { // Disabled state
.btn.disabled,
.btn[disabled] {
cursor: default; cursor: default;
background-image: none; background-image: none;
background-color: darken(@white, 10%); background-color: darken(@white, 10%);
.opacity(65); .opacity(65);
.box-shadow(none); .box-shadow(none);
} }
// Button Sizes
&.large { // Button Sizes
// --------------------------------------------------
// Large
.btn.large {
padding: 9px 14px; padding: 9px 14px;
font-size: @baseFontSize + 2px; font-size: @baseFontSize + 2px;
line-height: normal; line-height: normal;
.border-radius(5px); .border-radius(5px);
} }
&.large .icon { .btn.large .icon {
margin-top: 1px; margin-top: 1px;
} }
&.small {
// Small
.btn.small {
padding: 5px 9px; padding: 5px 9px;
font-size: @baseFontSize - 2px; font-size: @baseFontSize - 2px;
line-height: @baseLineHeight - 2px; line-height: @baseLineHeight - 2px;
} }
&.small .icon { .btn.small .icon {
margin-top: -1px; margin-top: -1px;
}
} }
// Help Firefox not be a jerk about adding extra padding to buttons
// Alternate buttons
// --------------------------------------------------
// Set text color
// -------------------------
.btn.primary,
.btn.primary:hover,
.btn.warning,
.btn.warning:hover,
.btn.danger,
.btn.danger:hover,
.btn.success,
.btn.success:hover,
.btn.info,
.btn.info:hover {
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
color: @white
}
// Provide *some* extra contrast for those who can get it
.btn.primary.active,
.btn.warning.active,
.btn.danger.active,
.btn.success.active,
.btn.info.active {
color: rgba(255,255,255,.75);
}
// Set the backgrounds
// -------------------------
.btn.primary {
.buttonBackground(@primaryButtonBackground, spin(@primaryButtonBackground, 20));
}
// Warning appears are orange
.btn.warning {
.buttonBackground(lighten(@orange, 15%), @orange);
}
// Danger and error appear as red
.btn.danger {
.buttonBackground(#ee5f5b, #bd362f);
}
// Success appears as green
.btn.success {
.buttonBackground(#62c462, #51a351);
}
// Info appears as a neutral blue
.btn.info {
.buttonBackground(#5bc0de, #2f96b4);
}
// Cross-browser Jank
// --------------------------------------------------
button.btn, button.btn,
input[type="submit"].btn { input[type="submit"].btn {
&::-moz-focus-inner { &::-moz-focus-inner {