Andamio nga

Ti bootstrap ket naibangon kadagiti makasungbat a 12-kolum a grid, layout, ken dagiti paset.

Kasapulan ti HTML5 a doctype

Ti Bootstrap ket agus-usar kadagiti sumagmamano nga elemento ti HTML ken dagiti tagikua ti CSS a kasapulan ti panagusar ti doctype ti HTML5. Iramanmo dayta iti rugi ti amin a proyektom.

  1. <!DOKTIPO TI html>
  2. <html lang = "ilo" >
  3. ...
  4. </html>

Tipograpia ken dagiti silpo

Ti Bootstrap ket mangikeddeng kadagiti batayan a sangalubongan a panagiparang, tipograpia, ken dagiti estilo ti silpo. Espesipiko, datayo:

  • Ikkaten marginiti bagi
  • Itakderan background-color: white;tibody
  • Usaren ti @baseFontFamily, @baseFontSize, ken @baseLineHeightdagiti attribute a kas ti tipograpiko a batayantayo
  • Itakderan ti sangalubongan a kolor ti silpo babaen @linkColorken iyaplikar ti link underlines laeng iti:hover

Dagitoy nga estilo ket mabalin a masarakan iti uneg ti andamio.less .

I-reset babaen ti Normalize

Iti Bootstrap 2, ti daan a bloke ti panag-reset ket naibaba a pabor iti Normalize.css , ti maysa a proyekto babaen ni Nicolas Gallagher a mangpabileg pay ti HTML5 Boilerplate . Bayat nga us-usarenmi ti kaaduan a Normalize iti uneg ti reset.less -mi , inikkatmi ti sumagmamano nga elemento nga espesipiko para iti Bootstrap.

Live nga grid nga pagarigan

Ti kasisigud a sistema ti grid ti Bootstrap ket agus-usar kadagiti 12 a kolum , a mangaramid para iti 940px a kalawa a pagkargaan nga awan dagiti makasungbat a tampok a napalubosan. Iti nainayon ti makasungbat a CSS a papeles, ti grid ket makibagay nga agbalin a 724px ken 1170px ti kalawana depende iti viewport-mo. Iti baba dagiti 767px a viewport, dagiti adigi ket agbalin a pluido ken agtumpok a bertikal.

1 nga
1 nga
1 nga
1 nga
1 nga
1 nga
1 nga
1 nga
1 nga
2. 2
3.
4.
4.
5.
9 nga

Batayan nga grid nga HTML

Para iti simple a dua a kolum a layout, mangpartuat ti maysa .rowken inayon ti maitutop a bilang dagiti .span*kolum. Kas daytoy ket maysa a 12-a-kolum a grid, tunggal maysa .span*ket mangsaklaw ti bilang kadagita a 12 a kolum, ken kanayon koma a mangnayon aginggana ti 12 para iti tunggal maysa a hilera (wenno ti bilang dagiti adigi iti nagannak).

  1. <div class="row">
  2. <div class="span4">...</div>
  3. <div class="span8">...</div>
  4. </div>

Given this example, we have .span4 and .span8, making for 12 total columns and a complete row.

Offsetting columns

Move columns to the left using .offset* classes. Each class increases the left margin of a column by a whole column. For example, .offset4 moves .span4 over four columns.

4
3 offset 2
3 offset 1
3 offset 2
6 offset 3
  1. <div class="row">
  2. <div class="span4">...</div>
  3. <div class="span3 offset2">...</div>
  4. </div>

Nesting columns

To nest your content with the default grid, add a new .row and set of .span* columns within an existing .span* column. Nested rows should include a set of columns that add up to the number of columns of its parent.

Example

Here two nested .span4 columns are placed within a .span8.

Level 1 of column
Level 2
Level 2
  1. <div class="row">
  2. <div class="span9">
  3. Level 1 column
  4. <div class="row">
  5. <div class="span6">Level 2</div>
  6. <div class="span3">Level 2</div>
  7. </div>
  8. </div>
  9. </div>

Live fluid grid example

The fluid grid system uses percents instead of pixels for column widths. It has the same responsive capabilities as our fixed grid system, ensuring proper proportions for key screen resolutions and devices.

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
8
6
6
12

Basic fluid grid HTML

Make any row "fluid" by changing .row to .row-fluid. The column classes stay the exact same, making it easy to flip between fixed and fluid grids.

  1. <div class="row-fluid">
  2. <div class="span4">...</div>
  3. <div class="span8">...</div>
  4. </div>

Fluid offsetting

Operates the same way as the fixed grid system offsetting: add .offset* to any column to offset by that many columns.

4
4 offset 4
3 offset 3
3 offset 3
6 offset 6
  1. <div class="row-fluid">
  2. <div class="span4">...</div>
  3. <div class="span4 offset2">...</div>
  4. </div>

Fluid nesting

Nesting with fluid grids is a bit different: the number of nested columns should not match the parent's number of columns. Instead, each level of nested columns are reset because each row takes up 100% of the parent column.

Fluid 12
Fluid 6
Fluid 6
  1. <div class="row-fluid">
  2. <div class="span12">
  3. Level 1 of column
  4. <div class="row-fluid">
  5. <div class="span6">Level 2</div>
  6. <div class="span6">Level 2</div>
  7. </div>
  8. </div>
  9. </div>

Fixed layout

Provides a common fixed-width (and optionally responsive) layout with only <div class="container"> required.

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

Fluid layout

Create a fluid, two-column page with <div class="container-fluid">—great for applications and docs.

  1. <div class="container-fluid">
  2. <div class="row-fluid">
  3. <div class="span2">
  4. <!--Sidebar content-->
  5. </div>
  6. <div class="span10">
  7. <!--Body content-->
  8. </div>
  9. </div>
  10. </div>

Enabling responsive features

Turn on responsive CSS in your project by including the proper meta tag and additional stylesheet within the <head> of your document. If you've compiled Bootstrap from the Customize page, you need only include the meta tag.

  1. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  2. <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">

Heads up! Bootstrap doesn't include responsive features by default at this time as not everything needs to be responsive. Instead of encouraging developers to remove this feature, we figure it best to enable it as needed.

About responsive Bootstrap

Dagiti makasungbat nga alikamen

Media queries allow for custom CSS based on a number of conditions—ratios, widths, display type, etc—but usually focuses around min-width and max-width.

  • Modify the width of column in our grid
  • Stack elements instead of float wherever necessary
  • Resize headings and text to be more appropriate for devices

Use media queries responsibly and only as a start to your mobile audiences. For larger projects, do consider dedicated code bases and not layers of media queries.

Supported devices

Bootstrap supports a handful of media queries in a single file to help make your projects more appropriate on different devices and screen resolutions. Here's what's included:

Label Layout width Column width Gutter width
Phones 480px and below Fluid columns, no fixed widths
Phones to tablets 767px and below Fluid columns, no fixed widths
Portrait tablets 768px and above 42px 20px
Default 980px and up 60px 20px
Large display 1200px and up 70px 30px
  1. /* Landscape phones and down */
  2. @media (max-width: 480px) { ... }
  3.  
  4. /* Landscape phone to portrait tablet */
  5. @media (max-width: 767px) { ... }
  6.  
  7. /* Portrait tablet to landscape and desktop */
  8. @media (min-width: 768px) and (max-width: 979px) { ... }
  9.  
  10. /* Large desktop */
  11. @media (min-width: 1200px) { ... }

Responsive utility classes

For faster mobile-friendly development, use these utility classes for showing and hiding content by device. Below is a table of the available classes and their effect on a given media query layout (labeled by device). They can be found in responsive.less.

Class Phones 767px and below Tablets 979px to 768px Desktops Default
.visible-phone Visible
.visible-tablet Visible
.visible-desktop Visible
.hidden-phone Visible Visible
.hidden-tablet Visible Visible
.hidden-desktop Visible Visible

When to use

Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.

Responsive utilities test case

Resize your browser or load on different devices to test the above classes.

Visible on...

Dagiti berde a marka ti tsek ket mangipakita a ti klase ket makita iti agdama a viewport-mo.

  • Telepono✔ Telepono nga
  • Tableta nga✔ Tableta nga
  • Desktop nga✔ Desktop nga

Nailemmeng iti...

Ditoy, dagiti berde a marka ti tsek ket mangipakita a ti klase ket nailemmeng iti agdama a viewport-mo.

  • Telepono✔ Telepono nga
  • Tableta nga✔ Tableta nga
  • Desktop nga✔ Desktop nga