user2045103
user2045103

Reputation: 51

How to inherit in element in less like class stacking?

we want to inherit from bootstraps h1 in less using a mixin like

.btn2{ .btn; }

but instead want to use the h1 element:

.h1_replace{ h1; }

Upvotes: 5

Views: 3387

Answers (2)

thiirteen
thiirteen

Reputation: 103

You could use an extend:

.h1_replace:extend(h1) {}

http://lesscss.org/features/#extend-feature

Upvotes: 2

David Fritsch
David Fritsch

Reputation: 3731

I do not believe that less supports that type of class inheritance. Instead you would likely have to redefine the h1 styling as a class and inherit that.

.h1 {
    /* copy h1 style here */
}

.h1_replace{ 
    .h1;
}

Though if you do this, you probably could just use the .h1 class throughout your code.

Upvotes: 2

Related Questions