Compile Twitter’s Bootstrap 3 without responsive features

Bootstrap 3 will be mobile first. No more separate responsive CSS file. Nice, but what if you don’t need / want the responsive features for some reason? So i try to compile Compile Twitter’s Bootstrap 3 without responsive features.

First i made a list of all less files writing media queries:

./print.less:@media print {
./modals.less:@media screen and (min-width: @screen-tablet) {
./carousel.less:@media screen and (min-width: @screen-tablet) {
./responsive-utilities.less:@media screen and (max-width: 400px) {
./responsive-utilities.less:@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
./responsive-utilities.less:@media (min-width: @screen-desktop) {
./responsive-utilities.less:@media print {
./jumbotron.less: @media screen and (min-width: @screen-tablet) {
./grid.less:@media (min-width: @screen-tablet) {
./grid.less:@media (min-width: @screen-desktop) {
./grid.less:@media (min-width: @screen-large-desktop) {
./navbar.less:@media screen and (min-width: @grid-float-breakpoint) {
./mixins.less: @media
./mixins.less: @media (min-width: @screen-small) {
./mixins.less: @media (min-width: @grid-float-breakpoint) {
./mixins.less: @media (min-width: @grid-float-breakpoint) {
./mixins.less: @media (min-width: @grid-float-breakpoint) {
./mixins.less: @media (min-width: @grid-float-breakpoint) {
./forms.less:@media (min-width: 768px) {

The basic idea will be drop the breakpoint and disable all grids except from the 960px (@screen-desktop) one.

I don’t need responsive-utilities.less so i remove it from bootstrap.less. Why does it file contains a “@media print” media query?

// Print utilities
.visible-print {
.responsive-invisibility();
}
.hidden-print { }

@media print {
.visible-print {
.responsive-visibility();
}
.hidden-print {
.responsive-invisibility();
}
}

See also: https://github.com/twitter/bootstrap/issues/8460

I should expect this in print.less, but for this reason i can’t remove responsive-visibility/responsive-invisibility. You will find this functions in mixins.less. (see: )
I also drop jumbotron.less. Why should i need this at all?

After this i look to: “./modals.less:@media screen and (min-width: @screen-tablet)”, “./carousel.less:@media screen and (min-width: @screen-tablet)”, “./navbar.less:@media screen and (min-width: @grid-float-breakpoint)”, “./forms.less:@media (min-width: 768px)”. The hardcoded 768px is a mistake i think, see also: https://github.com/twitter/bootstrap/pull/8454.

@grid-float-breakpoint will defined in variables.less as “@grid-float-breakpoint: @screen-tablet;”. On the first sight i should think this should be: “./modals.less: @media screen and (min-width: @grid-float-breakpoint)”, “./carousel.less:@media screen and (min-width: @grid-float-breakpoint)”, “./navbar.less:@media screen and (min-width: @grid-float-breakpoint)”, “./forms.less:@media (min-width: @grid-float-breakpoint)”. Cause this setting depend on a breakpoint which should be independent of the grid sizes (@screen-tablet). see: https://github.com/twitter/bootstrap/issues/8459

To compile my first non responsive version i have set them all to @grid-float-breakpoint with @grid-float-breakpoint : 0px. This works well for the forms where this breakpoint sets the right alignment for the form labels. Now the alignment is always right which could be okay for a non responsive site. For the dialog the effect will a fixed width of 560 pixels in stead of a 100% (auto) width. For a non responsive site we should prefer this too. Overall it doesn’t matter cause i will replace grid.less and don’t use @screen-tablet any more.

At least i changed grid.less to:


//
// Grid system
// --------------------------------------------------

// Set the container width, and override it for fixed navbars in media queries
.container {
.container-fixed();
}

// Mobile-first defaults
.row {
.make-row();
}

// Common styles for small and large grid columns
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12,
{
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: (@grid-gutter-width / 2);
padding-right: (@grid-gutter-width / 2);
}

//
// Container and grid column sizing
//

// Tiny device columns (smartphones)
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12 {
float: left;
}
.col-1 { width: percentage((1 / @grid-columns)); }
.col-2 { width: percentage((2 / @grid-columns)); }
.col-3 { width: percentage((3 / @grid-columns)); }
.col-4 { width: percentage((4 / @grid-columns)); }
.col-5 { width: percentage((5 / @grid-columns)); }
.col-6 { width: percentage((6 / @grid-columns)); }
.col-7 { width: percentage((7 / @grid-columns)); }
.col-8 { width: percentage((8 / @grid-columns)); }
.col-9 { width: percentage((9 / @grid-columns)); }
.col-10 { width: percentage((10/ @grid-columns)); }
.col-11 { width: percentage((11/ @grid-columns)); }
.col-12 { width: 100%; }

// Push and pull columns for source order changes
.col-push-1 { left: percentage((1 / @grid-columns)); }
.col-push-2 { left: percentage((2 / @grid-columns)); }
.col-push-3 { left: percentage((3 / @grid-columns)); }
.col-push-4 { left: percentage((4 / @grid-columns)); }
.col-push-5 { left: percentage((5 / @grid-columns)); }
.col-push-6 { left: percentage((6 / @grid-columns)); }
.col-push-7 { left: percentage((7 / @grid-columns)); }
.col-push-8 { left: percentage((8 / @grid-columns)); }
.col-push-9 { left: percentage((9 / @grid-columns)); }
.col-push-10 { left: percentage((10/ @grid-columns)); }
.col-push-11 { left: percentage((11/ @grid-columns)); }

.col-pull-1 { right: percentage((1 / @grid-columns)); }
.col-pull-2 { right: percentage((2 / @grid-columns)); }
.col-pull-3 { right: percentage((3 / @grid-columns)); }
.col-pull-4 { right: percentage((4 / @grid-columns)); }
.col-pull-5 { right: percentage((5 / @grid-columns)); }
.col-pull-6 { right: percentage((6 / @grid-columns)); }
.col-pull-7 { right: percentage((7 / @grid-columns)); }
.col-pull-8 { right: percentage((8 / @grid-columns)); }
.col-pull-9 { right: percentage((9 / @grid-columns)); }
.col-pull-10 { right: percentage((10/ @grid-columns)); }
.col-pull-11 { right: percentage((11/ @grid-columns)); }

// Offsets
.col-offset-1 { margin-left: percentage((1 / @grid-columns)); }
.col-offset-2 { margin-left: percentage((2 / @grid-columns)); }
.col-offset-3 { margin-left: percentage((3 / @grid-columns)); }
.col-offset-4 { margin-left: percentage((4 / @grid-columns)); }
.col-offset-5 { margin-left: percentage((5 / @grid-columns)); }
.col-offset-6 { margin-left: percentage((6 / @grid-columns)); }
.col-offset-7 { margin-left: percentage((7 / @grid-columns)); }
.col-offset-8 { margin-left: percentage((8 / @grid-columns)); }
.col-offset-9 { margin-left: percentage((9 / @grid-columns)); }
.col-offset-10 { margin-left: percentage((10/ @grid-columns)); }
.col-offset-11 { margin-left: percentage((11/ @grid-columns)); }

.container {
max-width: @container-desktop;
}

 

Now you will have a non responsive grid. Remember use “.col-” as class prefix for your grid rows now. Try it yourself and download the css file from: https://github.com/bassjobsen/non-responsive-tb3

18 Responses to “Compile Twitter’s Bootstrap 3 without responsive features”

  1. Ash

    Hi this is great, as I don’t want the responsive stuff for a project I’m working on, but do you have the less files available to replace the TB 3 ones?

    Reply
  2. Ash

    Hi, That’s the compiled css files, but do you have the original .less files you changed too?

    Reply
  3. Jack

    Thanks so much.

    I predict that Bootstrap 3.0 will get huge push-back for not supporting fixed width layouts.
    Not everyone wants stretchy web sites.

    Reply
  4. Jack

    Hallo Bass:

    Again, appreciate your work. However, the responsiveness continues below 768 pixels or so.
    What a shame. I will have to go back to Bootstrap 2.

    By the way, two of the github links above do a 404.

    Groeten,
    Jack

    Reply
  5. Elliot

    Hello

    Thanks for this, I’m making a Chrome Extension which is only 500px wide and thus having it responsive sucks.

    One issue I have though with the CSS: When I have a dropdown menu in my navbar it is pushing the navbar area down and the list items are stretched horizontally (like the mobile menu). I would like this to work as if I am on a desktop (a nice overlay popup). Any idea how?

    Reply
  6. WebAtMe

    Hello,

    I’m trying to use your script but unfortunately, i don’t know how.

    I’ve try to add the file “bootstrap.less” in my header but nothing change.

    Maybe i need to rename “bootstrap.less” in “bootstrap.less.css” and the same for all *.less files?

    I’ve miss something :-/

    Thanks

    Reply

Leave a Reply

(will not be published)