0

I am using Twitter's bootstrap LESS in a project and I am trying to setup a form but I can't seem to use .control-label; on my label. This is my code:

label { .control-label; }

I have read somewhere I should use the namespace .form-horizontal > .control-label; but that doesn't seem to work. Am I doing something wrong?

Mike Bovenlander
  • 5,236
  • 5
  • 28
  • 47
  • 1
    What you have should work. Are you sure you have included the file that `.control-label` is defined in? Which is forms.less I believe. How are you compiling your LESS? – hungerstar Aug 19 '14 at 13:48
  • I have included bootstrap.less that file includes forms.less but to make sure i have all so included forms.less. Sadly that didn't work :( – Mike Bovenlander Aug 20 '14 at 06:22
  • oh and LESS is compiled by a VS2013 plugin called webessentials. – Mike Bovenlander Aug 20 '14 at 06:28
  • As @seven-phases-max has pointed out below your issue has to do with scope. `.control-label` is defined inside of `.form-inline` of the forms.less file. Attempting to call/use `.control-label` outside of the `.form-inline` definition won't work as it only exists inside of `.form-inline`. – hungerstar Aug 20 '14 at 13:21

1 Answers1

0
.control-label:extend(.label) {
  additional props
}
Axel
  • 3,331
  • 11
  • 35
  • 58
  • hope that is what you are looking for :) – Axel Aug 19 '14 at 13:43
  • That doesn't work, the `label` should get the same properties as the .control-label class. – Mike Bovenlander Aug 19 '14 at 13:44
  • ah alright got it just a moment just have to check for less. I'm used to sass – Axel Aug 19 '14 at 13:46
  • 1
    @Axel the OP should be able to use the CSS class as a Mixin as they posted in their question. I'm thinking there is an issue with the OP's setup. – hungerstar Aug 19 '14 at 14:07
  • 1
    @hungerstar Only if the class is actually defined in a scope visible at the point you try to invoke it. `.control-label` [*is not*](https://github.com/twbs/bootstrap/blob/v3.2.0/less/forms.less#L431) in fact, so OP's result is expected. See also very similar http://stackoverflow.com/questions/24240134. – seven-phases-max Aug 19 '14 at 14:27
  • A yes, scope. My apologies for overlooking that. – hungerstar Aug 19 '14 at 15:45