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
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?
admin
Hi Ash,
Thanks for your response. Yes, you could download them from https://github.com/bassjobsen/non-responsive-tb3.
Regards, Bass
Ash
Hi, That’s the compiled css files, but do you have the original .less files you changed too?
admin
Hi Ash, i add the less file to https://github.com/bassjobsen/non-responsive-tb3 too. All updated to Bootstrap 3 RC1
Ash
That’s great! Thanks.
Bruno
Thank you!
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.
admin
Hallo Jack,
Thanks for your response. I will check the github links.
About the stretchy web sites and the responsiveness. Please read also.
The layout will be fluid for all grids now, but the .container class will give your website a max width (depending on your screen width). The large grid container has a max width of 1170 pixels. For a max width of 940 you will need one media query only.
Yes you’re right about the responsiveness from <768. The Small grid will stack from 767 pixels and lower. You can change this value easily, see: http://stackoverflow.com/questions/17919225/twitters-bootstrap-3-grid-changing-breakpoint-and-removing-padding/17920693
Groetjes, Bass
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
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?
admin
Hi Elliot,
Could you provide a demo to show what you need. Your menu is 500px width and not collapsed?
Not collapsed menus should have a overlay dropmenu. Please also check this question: http://stackoverflow.com/questions/18185693/collapsed-dropdown-menus-lost-in-bootstrap-3/18197094.
Regards, Bass
Elliot
Sure, take a look at this: http://i.imgur.com/qrPqPWj.png
So as you can see, the popup is 500px (with a set height). That format is exactly how I want it, without the collapsible button to trigger the menu. To get it like this, I used the CSS you provided at GitHub.
However, when I click on the “dropdown” link, I get the following: http://i.imgur.com/14lgS0v.png I would like the dropdown to function as if I’m on a full desktop view (if you understand).
The HTML I am using: http://pastebin.com/uY9882wG
If I put the list within the navbar-header, I get some odd results. Sometimes the menu looks fine, and other times it is placed below the “brand” – either way, the drop down doesn’t seem to work.
admin
Hi Elliot, i found your issue. See: https://github.com/bassjobsen/non-responsive-tb3/issues/2 and try the latest version from github.
Elliot
Awesome, thanks for the fix 🙂 Works perfectly now.
admin
Great. Cause your small screen also check this; http://stackoverflow.com/questions/18374468/twitters-bootstrap-3-dropdown-mega-menu-going-out-of-browser/18390390
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
admin
Hi, download the CSS file from https://github.com/bassjobsen/non-responsive-tb3 and use that.