Sudheer Sudheer - 11 months ago 64
Sass (Sass) Question

Copy Bootstrap styles to my CSS class

I want to apply Bootstrap's list-group styles to my selector

my_class > some_selector > ul
my_class > some_selector > ul > li

I want to use the same styles as list-group styles of Bootstrap. Is it possible to copy the styles of list-group and list-group-item to my selectors?

I am using bootstrap-sass and Bootstrap 3.x.


You can use SASS' extend for this. A nice example is provided in their documentation.

Basically, in your rule, you can add @extend .bootstrap-class to add those properties to your selector.

More specifically for list-group, you probably want something along the lines of:

.my_class > some_selector > ul {
  @extend .list-group;
  /* custom styles */

  > li {
    @extend .list-group-item;
    /* custom styles */