Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap - Do I have to add that class to every element?

In CSS I'm used to define styles globally for all elements like button { /* style stuff */ }

Is there a way to set all buttons to bootstraps btn btn-sm btn-default without explicitly setting the class for every element?

For example something like

button {
  btn btn-sm btn-default
}
like image 896
das Keks Avatar asked Sep 10 '25 06:09

das Keks


1 Answers

If you are familiar with LESS, you could edit the bootstrap core and prepend each .btn with button, so .btn, button, and recompile the less. buttons.less is the file you want to be looking at.

Alternatively, just do a search and replace for ".btn {" and replace it with ".btn, button {" in the compiled css of bootstrap. Although you will have to do this multiple times and be quite careful, since there are a lot of subclasses in bootstrap (.btn-default, .btn-primary and so on).

like image 184
bitten Avatar answered Sep 12 '25 19:09

bitten