Dynamic class to element with Less

2019-08-06 19:07发布

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
}

1条回答
放荡不羁爱自由
2楼-- · 2019-08-06 19:47

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.

查看更多
登录 后发表回答