Search code examples
csstwitter-bootstraplessbootswatch

Dynamic class to element with Less


I am using bootstrap.less and i want to add class="table table-striped table-hover" to all tables. Is it possible to achieve this?

I want to add something like:

table {
   //Add class here
}

Solution

  • If I understand you correctly, I believe you're looking for:

    table {
      .table;
      .table-striped;
      .table-hover;
    
      /* Any other default table styles */
    }
    

    While you can't add class="table table-striped table-hover" to each element (that's more in the JS-realm), you can get the same effect by using the other classes as mixins added to the default table element's styles. See the LESS documentation for more examples.