ccc28615e2edca091ee3d5beaf461df4ff95d732.svn-base 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ---
  2. layout: docs
  3. title: Overview
  4. group: layout
  5. redirect_from: "/layout/"
  6. ---
  7. Bootstrap includes several components and options for laying out your project, including wrapping containers, a powerful grid system, a flexible media object, and responsive utility classes.
  8. ## Containers
  9. Containers are the most basic layout element in Bootstrap and are **required when using our grid system**. Choose from a responsive, fixed-width container (meaning it's `max-width` changes at each breakpoint) or fluid-width (meaning it's `100%` wide all the time).
  10. While containers *can* be nested, most layouts do not require a nested container.
  11. <div class="bd-example">
  12. <div class="bd-example-container">
  13. <div class="bd-example-container-header"></div>
  14. <div class="bd-example-container-sidebar"></div>
  15. <div class="bd-example-container-body"></div>
  16. </div>
  17. </div>
  18. {% highlight html %}
  19. <div class="container">
  20. <!-- Content here -->
  21. </div>
  22. {% endhighlight %}
  23. Use `.container-fluid` for a full width container, spanning the entire width of the viewport.
  24. <div class="bd-example">
  25. <div class="bd-example-container bd-example-container-fluid">
  26. <div class="bd-example-container-header"></div>
  27. <div class="bd-example-container-sidebar"></div>
  28. <div class="bd-example-container-body"></div>
  29. </div>
  30. </div>
  31. {% highlight html %}
  32. <div class="container-fluid">
  33. ...
  34. </div>
  35. {% endhighlight %}
  36. ## Responsive breakpoints
  37. Since Bootstrap is developed to be mobile first, we use a handful of [media queries](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries) to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.
  38. Bootstrap primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.
  39. {% highlight scss %}
  40. // Extra small devices (portrait phones, less than ???px)
  41. // No media query since this is the default in Bootstrap
  42. // Small devices (landscape phones, 34em and up)
  43. @media (min-width: 34em) { ... }
  44. // Medium devices (tablets, 48em and up)
  45. @media (min-width: 48em) { ... }
  46. // Large devices (desktops, 62em and up)
  47. @media (min-width: 62em) { ... }
  48. // Extra large devices (large desktops, 75em and up)
  49. @media (min-width: 75em) { ... }
  50. {% endhighlight %}
  51. Since we write our source CSS in Sass, all our media queries are available via Sass mixins:
  52. {% highlight scss %}
  53. @include media-breakpoint-up(xs) { ... }
  54. @include media-breakpoint-up(sm) { ... }
  55. @include media-breakpoint-up(md) { ... }
  56. @include media-breakpoint-up(lg) { ... }
  57. @include media-breakpoint-up(xl) { ... }
  58. // Example usage:
  59. @include media-breakpoint-up(sm) {
  60. .some-class {
  61. display: block;
  62. }
  63. }
  64. {% endhighlight %}
  65. We occasionally use media queries that go in the other direction (the given screen size *or smaller*):
  66. {% highlight scss %}
  67. // Extra small devices (portrait phones, less than 34em)
  68. @media (max-width: 33.9em) { ... }
  69. // Small devices (landscape phones, less than 48em)
  70. @media (max-width: 47.9em) { ... }
  71. // Medium devices (tablets, less than 62em)
  72. @media (max-width: 61.9em) { ... }
  73. // Large devices (desktops, less than 75em)
  74. @media (max-width: 74.9em) { ... }
  75. // Extra large devices (large desktops)
  76. // No media query since the extra-large breakpoint has no upper bound on its width
  77. {% endhighlight %}
  78. Once again, these media queries are also available via Sass mixins:
  79. {% highlight scss %}
  80. @include media-breakpoint-down(xs) { ... }
  81. @include media-breakpoint-down(sm) { ... }
  82. @include media-breakpoint-down(md) { ... }
  83. @include media-breakpoint-down(lg) { ... }
  84. @include media-breakpoint-down(xl) { ... }
  85. {% endhighlight %}