Twitter Bootstrap

Bootstrap hè un toolkit da Twitter pensatu per kickstart u sviluppu di webapps è siti.
Include CSS basi è HTML per a tipografia, forme, buttoni, tavule, griglie, navigazione è più.

Nerd alert: Bootstrap hè custruitu cù Less è hè statu cuncepitu per travaglià fora di a porta cù solu navigatori muderni in mente.

Hotlink u CSS

Per u principiu più rapidu è faciule, basta copiate stu snippet in a vostra pagina web.

Aduprate cù Less

Un fan di utilizà Less? Nisun prublema, basta clone u repo è aghjunghje queste linee:

Fork nantu à GitHub

Scaricate, forchetta, tirate, prublemi di schedari, è più cù u repo ufficiale di Bootstrap in Github.

Bootstrap nantu à GitHub »

Griglia predeterminata

U sistema di griglia predeterminatu furnitu cum'è parte di Bootstrap hè una griglia larga 940px di 16 colonne. Hè un sapori di u famosu sistema di griglia 960, ma senza u margine / padding supplementu nantu à i lati manca è destra.

Esempiu di marcatura di griglia

Cum'è mostratu quì, un layout di basa pò esse creatu cù duie "columne", ognuna spanning un numeru di e 16 culonni fundamentali chì avemu definitu cum'è parte di u nostru sistema di griglia. Vede l'esempii sottu per più variazioni.

  1. <div class="row"> class = "fila" >
  2. <div class = "span6 columns" >
  3. ...
  4. </div>
  5. <div class = "span10 columns" >
  6. ...
  7. </div>
  8. </div>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
3
3
3
3
3
1
4
4
4
4
4
6
6
8
8
5
11
16

Colonne di compensazione

4
8 offset 4
4 offset 4
4 offset 4
5 offset 3
5 offset 3
10 offset 6

Disposizione fissa

Un cuntainer di basa di 940px largu, centratu per quasi ogni situ o pagina.

  1. <corpu>
  2. <div class = "container" >
  3. ...
  4. </div>
  5. </corpu>

Disposizione fluida

Una struttura di pagina fluida o liquida flessibile cù larghezza minima è massima è una barra laterale di sinistra. Grande per l'applicazioni.

  1. <corpu>
  2. <div class = "container-fluid" >
  3. <div class = "sidebar" >
  4. ...
  5. </div>
  6. <div class = "cuntenutu" >
  7. ...
  8. </div>
  9. </div>
  10. </corpu>

Intestazioni è copia

Una gerarchia tipografica standard per a strutturazione di e vostre pagine web.

h1. Titre 1

h2. Titre 2

h3. Titre 3

h4. Titre 4

h5. Titre 5
h6. Titre 6

Esempiu paràgrafu

Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Esempiu di intestazione Hà sottotitulu...

Pudete ancu aghjunghje sottutituli cù <strong>e<em>

Misc. elementi

Utilizendu enfasi, indirizzi è abbreviazioni

<strong> <em> <address> <abbr>

Quandu aduprà

I tag di enfasi ( <strong>è <em>) deve esse usatu per aghjunghje una distinzione visuale trà una parolla o frase è a so copia circundante. Aduprate <strong>per l'attenzione vechja è <em>per l' attenzione è i tituli.

Enfasi in un paràgrafu

Fusce dapibus , tellus ac cursus commodo , tortor mauris condimentum nibh , ut fermentum massa justo sit amet risus. Maecenas faucibus mollis interdum. Nulla vitae elit libero, a pharetra augue.

Indirizzi

L' addresselementu hè utilizatu per - l'avete invintatu ! - indirizzi. Eccu cumu si vede:

Twitter, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (123) 456-7890

Nota: Ogni linea in un addressdeve finisce cù una linea-break ( <br />) per strutturà currettamente u cuntenutu cum'è lettu in a vita reale senza alcunu stili applicati.

Abbreviazioni

Per l'abbreviazioni è l'acronimi, utilizate l' abbretichetta ( acronymhè deprecated in HTML5 ). Mettite a forma di shorthand in u tag è stabilisce un titulu per u nome cumpletu.

Blockquotes

<blockquote> <p> <cite>

Assicuratevi di imballà u vostru blockquoteattornu paragraphè citetag. Quandu citate una fonte, utilizate l' citeelementu. U CSS prefarà automaticamente un nome cù un dash em (—).

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

Dr Julius Hibbert

Listi

Senza ordine<ul>

  • Jeremy Bixby
  • Robert Dezure
  • Josh Washington
  • Anton Capresi
  • I mo cumpagni di squadra
    • George Castanza
    • Jerry Seinfeld
    • Cosmo Kramer
    • Elaine Bennis
    • Newman
  • Ghjuvan Ghjacobbu
  • Paul Pierce
  • Kevin Garnett

Unstyled<ul.unstyled>

  • Jeremy Bixby
  • Robert Dezure
  • Josh Washington
  • Anton Capresi
  • I mo cumpagni di squadra
    • George Castanza
    • Jerry Seinfeld
    • Cosmo Kramer
    • Elaine Bennis
    • Newman
  • Ghjuvan Ghjacobbu
  • Paul Pierce
  • Kevin Garnett

Cumandatu<ol>

  1. Jeremy Bixby
  2. Robert Dezure
  3. Josh Washington
  4. Anton Capresi
  5. I mo cumpagni di squadra
    1. George Castanza
    2. Jerry Seinfeld
    3. Cosmo Kramer
    4. Elaine Bennis
    5. Newman
  6. Ghjuvan Ghjacobbu
  7. Paul Pierce
  8. Kevin Garnett

Descrizzionedl

Lista di descrizzione
Una lista di descrizzione hè perfetta per definisce i termini.
Euismod
Vestibulum id ligula porta felis euismod sempre eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.

Custruì tavulini

<table> <thead> <tbody> <tr> <th> <td> <colspan> <caption>

I tavulini sò grandi - per parechje cose. Grandi tavule, però, anu bisognu di un pocu di markup love per esse utili, scalabili è leghjite (à u livellu di codice). Eccu uni pochi di cunsiglii per aiutà.

Imbulighjate sempre i vostri intestazioni di colonna in un theadtali chì a ghjerarchia hè thead> tr> th.

Simile à l'intestazione di a colonna, tuttu u cuntenutu di u corpu di a vostra tavula deve esse impannillatu in una tbodymanera chì a vostra ghjerarchia hè tbody> tr> td.

Esempiu: Stili di tabella predeterminati

Tutte e tavule seranu automaticamente stilate cù solu i cunfini essenziali per assicurà a leggibilità è mantene a struttura. Ùn ci hè bisognu di aghjunghje classi o attributi extra.

# Nomu Casata Lingua
1 Certi Unu Inglese
2 Joe Sixpack Inglese
3 Stu Dent Codice
  1. <table class="table-cumune"> class = "tavola cumuna" >
  2. ...
  3. </table>

Esempiu: Zebra-striped

Fate un pocu di fantasia cù i vostri tavulini aghjunghjendu zebra-striping - basta aghjunghje a .zebra-stripedclassa.

# Nomu Casata Lingua
1 Certi Unu Inglese
2 Joe Sixpack Inglese
3 Stu Dent Codice
  1. <table class="common-table zebra-striped"> class = "tavola cumuna zebra-striped" >
  2. ...
  3. </table>

Esempiu: Zebra-striped w/ TableSorter.js

Pigliendu l'esempiu precedente, migliurà l'utilità di e nostre tavule furnite una funziunalità di sorte via jQuery è u plugin Tablesorter . Cliccate nantu à l'intestazione di qualsiasi colonna per cambià a sorta.

# Nomu Casata Lingua
1 U vostru Unu Inglese
2 Joe Sixpack Inglese
3 Stu Dent Codice
  1. <script type="text/javascript" src="js/jquery/jquery.tablesorter.min.js"></script> type = "text/javascript" src = "js/jquery/jquery.tablesorter.min.js" ></script>
  2. <script type = "text/javascript" >
  3. $ ( documentu ). pronta ( funzione () {
  4. $ ( "table#sortTableExample" ). tablesorter ( { sortList : [[ 1 , 0 ]]} );
  5. });
  6. </script>
  7. <table class = "tavula cumuna zebra-striped" >
  8. ...
  9. </table>

Stili predeterminati

Tutte e forme sò datu stili predeterminati per presentà in una manera leggibile è scalabile. Stili sò furniti per inputs di testu, selezziunà listi, aree di testu, buttoni di radiu è caselle di verificazione, è buttoni.

Esempiu di legenda di forma
Qualchì valore quì
Picculu frammentu di testu d'aiutu
Esempiu di legenda di forma
@
Esempiu di legenda di forma
Nota: L'etichette circundanu tutte l'opzioni per aree di clicu assai più grande è una forma più utilizable.
à Tutti i tempi sò indicati cum'è Pacific Standard Time (GMT -08:00).
Bloccu di testu d'aiutu per descriverà u campu sopra se ne necessariu.

Forme impilate

Aghjunghjite .form-stackedà l'HTML di u vostru furmulariu è avete etichette nantu à i so campi invece di a so manca. Questu funziona bè se i vostri formi sò brevi o avete duie colonne di input per forme più pesanti.

Esempiu di legenda di forma
Esempiu di legenda di forma
Nota: L'etichette circundanu tutte l'opzioni per aree di clicu assai più grande è una forma più utilizable.

Bottoni

Comu cunvenzione, i buttoni sò usati per l'azzioni mentre i ligami sò usati per l'uggetti. Per esempiu, "Download" puderia esse un buttone è "attività recente" puderia esse un ligame.

Tutti i buttoni predeterminate à un stile grisgiu chjaru, ma una .primaryclassa blu hè dispunibule. In più, rotulà i vostri stili hè faciule faciule.

Esempi di buttoni

Stili di buttone pò esse appiicati à qualsiasi cosa cù l' .btnapplicata. Di genere, vulete applicà questi solu à elementi a, button, è selezziunate . inputEccu cumu si vede:

Taglie alternate

Vulete i buttoni più grande o più chjucu? Amparate!

Statu disattivatu

Per i buttoni chì ùn sò micca attivi o chì sò disattivati ​​da l'app per una ragione o un altru, utilizate u statu disattivatu. Hè .disabledper ligami è :disabledper buttonelementi.

Ligami

Bottoni

Basic alerts

One-line messages for highlighting the failure, possible failure, or success of an action. Particularly useful for forms.

×

Oh snap! Change this and that and try again.

×

Holy gaucamole! Best check yo self, you're not looking too good.

×

Well done! You successfully read this alert message.

×

Heads up! This is an alert that needs your attention, but it's not a huge priority just yet.

Block messages

For messages that require a bit of explanation, we have paragraph style alerts. These are perfect for bubbling up longer error messages, warning a user of a pending action, or just presenting information for more emphasis on the page.

×

Oh snap! You got an error! Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Take this action Or do this

×

Holy gaucamole! This is a warning! Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Take this action Or do this

×

Well done! You successfully read this alert message. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum.

Take this action Or do this

×

Heads up! This is an alert that needs your attention, but it's not a huge priority just yet.

Take this action Or do this

Modals

Modals—dialogs or lightboxes—are great for contextual actions in situations where it's important that the background context be maintained.

Tool Tips

Twipsies are super useful for aiding a confused user and pointing them in the right direction.

Lorem ipsum dolar sit amet illo error ipsum veritatis aut iste perspiciatis iste voluptas natus illo quasi odit aut natus consequuntur consequuntur, aut natus illo voluptatem odit perspiciatis laudantium rem doloremque totam voluptas. Voluptasdicta eaque beatae aperiam ut enim voluptatem explicabo explicabo, voluptas quia odit fugit accusantium totam totam architecto explicabo sit quasi fugit fugit, totam doloremque unde sunt sed dicta quae accusantium fugit voluptas nemo voluptas voluptatem rem quae aut veritatis quasi quae.

below!
right!
left!
above!

Popovers

Use popovers to provide subtextual information to a page without effecting layout.

Popover Title

Etiam porta sem malesuada magna mollis euismod. Maecenas faucibus mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.

Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.

Check out how we used Preboot in Bootstrap and how you can make use of it should you choose to run Less on your next project.

How to use it

Use this option to make full use of Bootstrap's Less variables, mixins, and nesting in CSS via javascript in your browser.

  1. <link rel="stylesheet/less" type="text/css" href="less/bootstrap.less" media="all" />
  2. <script type="text/javascript" src="js/less-1.0.41.min.js"></script>

Not feeling the .js solution? Try the Less Mac app or use Node.js to compile when you deploy your code.

What's included

Here are some of the highlights of what's included in Twitter Bootstrap as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.

Color variables

Variables in Less are perfect for maintaining and updating your CSS headache free. When you want to change a color value or a frequently used value, update it in one spot and you're set.

  1. // Links
  2. @linkColor: #8b59c2;
  3. @linkColorHover: darken(@linkColor, 10);
  4. // Grays
  5. @black: #000;
  6. @grayDark: lighten(@black, 25%);
  7. @gray: lighten(@black, 50%);
  8. @grayLight: lighten(@black, 70%);
  9. @grayLighter: lighten(@black, 90%);
  10. @white: #fff;
  11. // Accent Colors
  12. @blue: #08b5fb;
  13. @green: #46a546;
  14. @red: #9d261d;
  15. @yellow: #ffc40d;
  16. @orange: #f89406;
  17. @pink: #c3325f;
  18. @purple: #7a43b6;
  19. // Baseline
  20. @baseline: 20px;

Commenting

Less also provides another style of commenting in addition to CSS's normal /* ... */ syntax.

  1. // This is a comment
  2. /* This is also a comment */

Mixins up the wazoo

Mixins are basically includes or partials for CSS, allowing you to combine a block of code into one. They're great for vendor prefixed properties like box-shadow, cross-browser gradients, font stacks, and more. Below is a sample of the mixins that are included with Bootstrap.

Font stacks

  1. #font {
  2. .shorthand(@weight: normal, @size: 14px, @lineHeight: 20px) {
  3. font-size: @size;
  4. font-weight: @weight;
  5. line-height: @lineHeight;
  6. }
  7. .sans-serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  8. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  9. font-size: @size;
  10. font-weight: @weight;
  11. line-height: @lineHeight;
  12. }
  13. .serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  14. font-family: "Georgia", Times New Roman, Times, sans-serif;
  15. font-size: @size;
  16. font-weight: @weight;
  17. line-height: @lineHeight;
  18. }
  19. .monospace(@weight: normal, @size: 12px, @lineHeight: 20px) {
  20. font-family: "Monaco", Courier New, monospace;
  21. font-size: @size;
  22. font-weight: @weight;
  23. line-height: @lineHeight;
  24. }
  25. }

Gradients

  1. #gradient {
  2. .horizontal (@startColor: #555, @endColor: #333) {
  3. background-color: @endColor;
  4. background-repeat: repeat-x;
  5. background-image: -khtml-gradient(linear, left top, right top, from(@startColor), to(@endColor)); // Konqueror
  6. background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
  7. background-image: -ms-linear-gradient(left, @startColor, @endColor); // IE10
  8. background-image: -webkit-gradient(linear, left top, right top, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  9. background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  10. background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
  11. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor); // IE8+
  12. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor)); // IE6 & IE7
  13. background-image: linear-gradient(left, @startColor, @endColor); // Le standard
  14. }
  15. .vertical (@startColor: #555, @endColor: #333) {
  16. background-color: @endColor;
  17. background-repeat: repeat-x;
  18. background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor)); // Konqueror
  19. background-image: -moz-linear-gradient(@startColor, @endColor); // FF 3.6+
  20. background-image: -ms-linear-gradient(@startColor, @endColor); // IE10
  21. background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  22. background-image: -webkit-linear-gradient(@startColor, @endColor); // Safari 5.1+, Chrome 10+
  23. background-image: -o-linear-gradient(@startColor, @endColor); // Opera 11.10
  24. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor); // IE8+
  25. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE6 & IE7
  26. background-image: linear-gradient(@startColor, @endColor); // The standard
  27. }
  28. .directional (@startColor: #555, @endColor: #333, @deg: 45deg) {
  29. ...
  30. }
  31. .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 0.5, @endColor: #c3325f) {
  32. ...
  33. }
  34. }

Operations and grid system

Get fancy and perform some math to generate flexible and powerful mixins like the one below.

  1. // Griditude
  2. @gridColumns: 16;
  3. @gridColumnWidth: 40px;
  4. @gridGutterWidth: 20px;
  5. // Grid System
  6. .container {
  7. width: @siteWidth;
  8. margin: 0 auto;
  9. .clearfix();
  10. }
  11. .columns(@columnSpan: 1) {
  12. display: inline;
  13. float: left;
  14. width: (@gridColumnWidth * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1));
  15. margin-left: @gridGutterWidth;
  16. &:first-child {
  17. margin-left: 0;
  18. }
  19. }
  20. .offset(@columnOffset: 1) {
  21. margin-left: (@gridColumnWidth * @columnOffset) + (@gridGutterWidth * (@columnOffset - 1)) !important;
  22. }