CSS, my class can inherit from Bootstrap

Asked

Viewed 112 times

4

I have a system with old Look and Feel. The idea is to change to boorstrap. BUT with as little change as possible.

Concrete example. The buttons use the fwButton css class. It would be possible to make this class inherit the btn-Primary class properties from Bootstrap 4 ?

Without changing all html calls from class="fwButton" to class="btn btn-Primary" and without copying the btn-Primary class properties.

1 answer

4


Bjverde, use @extend

However, many authors discourage developers from using this feature. The reason is the generated CSS.

For example, say we have a class .error and we want to use her styles in another class.

.error {
  color: red;
}

.icon--error {
  @extend .error;
}

The generated CSS will be as follows:

.error, .icon--error {
  color: red;
}

But cater to what you need.

I hope I’ve helped

  • thanks just today I could understand that I need the SASS to get your tip. The link complements the question https://answall.com/questions/121684/qual-a-diferen%C3%A7a-e-when-to-use-mixin-e-extend-em-Sass

Browser other questions tagged

You are not signed in. Login or sign up in order to post.