From eadfa59d92ad8bd898b2586056fbbf55906e1420 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 2 Apr 2013 19:40:43 -0700 Subject: [PATCH] Add small grid for phones and tablets --- docs/_includes/docs-nav.html | 1 + docs/assets/css/bootstrap.css | 57 ++++++++++++++++++++++++++++++++++- docs/docs.html | 25 ++++++++++++--- less/grid.less | 12 ++++++-- less/mixins.less | 18 +++++++++++ 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/docs/_includes/docs-nav.html b/docs/_includes/docs-nav.html index f9670a0d82..fa20d9e985 100644 --- a/docs/_includes/docs-nav.html +++ b/docs/_includes/docs-nav.html @@ -18,6 +18,7 @@
  • Offset columns
  • Nested columns
  • Column ordering
  • +
  • Small device grid
  • LESS mixins and variables
  • diff --git a/docs/assets/css/bootstrap.css b/docs/assets/css/bootstrap.css index 44978573ef..b4b499e8f6 100644 --- a/docs/assets/css/bootstrap.css +++ b/docs/assets/css/bootstrap.css @@ -782,13 +782,66 @@ pre code { margin-left: -15px; } -[class*="col-span-"] { +[class*="col-span-"], +[class*="col-small-"] { position: relative; min-height: 1px; padding-right: 15px; padding-left: 15px; } +[class*="col-small-"] { + float: left; +} + +.col-small-span-12 { + width: 100%; +} + +.col-small-span-11 { + width: 91.66666666666666%; +} + +.col-small-span-10 { + width: 83.33333333333334%; +} + +.col-small-span-9 { + width: 75%; +} + +.col-small-span-8 { + width: 66.66666666666666%; +} + +.col-small-span-7 { + width: 58.333333333333336%; +} + +.col-small-span-6 { + width: 50%; +} + +.col-small-span-5 { + width: 41.66666666666667%; +} + +.col-small-span-4 { + width: 33.33333333333333%; +} + +.col-small-span-3 { + width: 25%; +} + +.col-small-span-2 { + width: 16.666666666666664%; +} + +.col-small-span-1 { + width: 8.333333333333332%; +} + @media screen and (min-width: 768px) { .container { max-width: 728px; @@ -5161,6 +5214,8 @@ a.list-group-item.active > .badge, font-size: 30px; } .carousel-caption { + right: 20%; + left: 20%; padding-bottom: 30px; } } diff --git a/docs/docs.html b/docs/docs.html index 517b81cfa8..73c81ff409 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -321,6 +321,8 @@ title: Bootstrap Documentation

    For improved cross-browser rendering, we use Normalize, a project by Nicolas Gallagher and Jonathan Neal.

    + +
    @@ -438,16 +440,31 @@ title: Bootstrap Documentation

    Column ordering

    Easily change the order of our built-in grid columns with .push* and .pull* modifier classes.

    -
    -
    9
    -
    3
    -
    +
    +
    9
    +
    3
    +
    {% highlight html linenos %}
    9
    3
    +{% endhighlight %} + +

    Small device grid

    +

    Use the small device grid classes, like .col-small-span-6, to create columned layouts on phone and tablet devices (anything under 768px). Offsets, pushes, and pulls are not available with the small grid at this time.

    +
    +
    4 cols, 6 small cols
    +
    4 cols, 6 small cols
    +
    4 cols, 12 small cols
    +
    +{% highlight html linenos %} +
    +
    4 cols, 6 small cols
    +
    4 cols, 6 small cols
    +
    4 cols, 12 small cols
    +
    {% endhighlight %}

    LESS mixins and variables

    diff --git a/less/grid.less b/less/grid.less index 1de1b15f6c..8162d99407 100644 --- a/less/grid.less +++ b/less/grid.less @@ -12,20 +12,28 @@ .row { .make-row(); } -[class*="col-span-"] { +[class*="col-span-"], +[class*="col-small-"] { position: relative; min-height: 1px; padding-left: (@grid-gutter-width / 2); padding-right: (@grid-gutter-width / 2); } +[class*="col-small-"] { + float: left; +} +.generate-small-grid-columns(@grid-columns); + // Responsive: Tablets and up @media screen and (min-width: 768px) { .container { max-width: 728px; } // Generate the grid columns and offsets - [class*="col-span-"] { float: left; } + [class*="col-span-"] { + float: left; + } .generate-grid-columns(@grid-columns); } diff --git a/less/mixins.less b/less/mixins.less index e57e83a12a..76c40df2da 100644 --- a/less/mixins.less +++ b/less/mixins.less @@ -501,6 +501,24 @@ .col-pull-X(@grid-columns); } +// Small device grid +.generate-small-grid-columns(@grid-columns) { + + // Deterimine the classes + .col-small-span-X (@index) when (@index > 0) { + .col-small-span-@{index} { .col-small-span-(@index); } + .col-small-span-X((@index - 1)); + } + .col-small-span-X(0) {} + + // Specify widths + .col-small-span-(@columns) { + width: percentage((@columns / @grid-columns)); + } + + // Generate the CSS + .col-small-span-X(@grid-columns); +} // Framework mixins