Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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; }
like image 350
user2045103 Avatar asked Oct 05 '22 03:10

user2045103


2 Answers

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.

like image 130
David Fritsch Avatar answered Oct 07 '22 16:10

David Fritsch


You could use an extend:

.h1_replace:extend(h1) {}

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

like image 38
thiirteen Avatar answered Oct 07 '22 16:10

thiirteen