twitter/bootstrap — Issue #2434: Bootstrap is not getting to its full potentiall...
Author: aartiPl
Created: 2012-03-06 21:27:48+00:00
State: open

Well, every author knows about she's baby that it is not perfect... But please let me identify few (high level) issues with current approach in Bootstrap, which could be quite easily fixed.

1. HTML is for semantic elements, and CSS is for visual formatting. It is well known for everyone... But when I was looking for best CSS framework over there, I found following answer on Stackoverflow:
http://stackoverflow.com/questions/203069/what-is-the-best-css-framework-and-are-they-worth-the-effort

Accepted answer has a good merits, so I was starting thinking how to solve it cleanly...

My conclusion was that using Less preprocessor it is quite easy. It's enough to have a whole framework as mixins and it is possible to make your own *.less, which will just import visual elements from bootstrap. Then no visual elements need to migrate into HTML.

E.g.

my.html
----------------------

my.less
----------------------
.menu {
.nav;
.nav-pills;
.nav-stackable;
}

instead of writing in HTML:

Above solution partially works. But only partially. Currently problem is that Bootstrap is not defined properly to mix classes into user LESS files. In above example there is e.g. error importing .nav-stackable. It is because .nav-stackable is not defined in "nested way" but traditionally:

// Stacked tabs and pills
.nav-stacked > li {
float: none;
}
.nav-stacked > li > a {
margin-right: 0; // no need for the gap between nav items
}

Because of that you can not mixin this class into your own *.less stylesheet (there is no simple .nav-stackable class - just descendants).

If it works it will be possible to completely get rid of visual elements from HTML, as you can always use your own having semantic meaning in your *.less file. There will be still problems with other selectors basing on .nav-stackable (which will be effectively renamed after mixin into client code), but I think it is a way to go nevertheless. Changing even part of Bootstrap can much improve situation.

2. It is another positive consequence of point 1.

Currently I am trying to create Joomla template using Bootstrap. Unfortunately it is not possible to get it right. The problem is that Joomla uses it's own tags in HTML, which are expanded into other HTML.

E.g.

is expanded into:

Home

test 1

and now I can not apply nav styles to ul list! It is generated by Joomla and I can not change it.

With Bootstrap defined as mixins it would be possible to make it in own *.less file as presented above:

.menu {
.nav;
.nav-pills;
.nav-stackable;
}

After these changes code in less files and in user HTML should be much cleaner and just better.