0

I want to do this

.bip_control{
    @extend .form-control;
    color:red;
}

but the resulting css looks like

.bip_control{
  color: red;
}

Am I missing something?

Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
  • I'm working with bootstrap in Ror and having no problems with @extend rule. I think that when you try to extend .form-control (which is definded in bootstrap stylesheets) you don't have the visibility of the class you're extending from your stylesheet as you're in your own stylesheet, i suppose. In the proposed answer, in fact, in sassmeister it is importing bootstrap stylesheet where the rule is defined and visible. – sissy Feb 13 '14 at 15:16

1 Answers1

0

I tried out your code and for me it seems to work as expected. Assuming you are importing the bootstrap files into the Sass file were you define .bip-control, as this is the only way you can extend the bootstrap rules with your selectors. I added an example on Sassmeister:

http://sassmeister.com/gist/8973529

@import "bootstrap";
.bip_control{
    @extend .form-control;
    color:red;
}

Importing bootstrap like this should include all bootstrap rules that you can extend (see here, however you can also import only individual components/mixins files, then you just need to make sure that you include the rules you want to extend and their dependencies).

If you look at the generated CSS, from line #2015 on, you will find all the .form-contro rules extended with the .bip_control selector.
For expample:

.form-control, .bip_control { ...
...
.form-control:focus, .bip_control:focus { ...
...

All the additional properties that belong only to .bip_control are added as another ruleset at the end of the rest of the imported bootstrap rules (or where ever you have defined it). This CSS rule set will also be returned, if the rules that you are trying to extend are not imported/included properly, and not available to the @extend directive.


You can maybe see better on how @extend works from the example in this answer (in case I haven't showed it well enough on the above bootstrap example): SCSS - override an @extend with another @extend

Community
  • 1
  • 1
Martin Turjak
  • 20,896
  • 5
  • 56
  • 76