extend bootstrap 4 margin sizing


extend bootstrap 4 margin sizing



I'm using bootstrap 4 with sass(scss file), and want to apply .mx-2 class properties into a new class. theorytically some thing like:


scss file


.mx-2


.MyCustomClass{
@extend .mx-2;
}



But apparently, compiler cannot find .mx-2 selector and it fails.
I know that mx-2 class created by using mixture of $size, $length, $spacers ,$breakpoint etc...
So i changed it:


.mx-2


mx-2


$size


$length


$spacers


$breakpoint


.MyCustomClass{
margin-left: ($spacer * .5) !important;
margin-right: ($spacer * .5) !important;
}



I'm wondering to know:


.5


.mx-lg-2




1 Answer
1



"But apparently, compiler cannot find .mx-2 selector and it fails."



It should work, but you need to @import "bootstrap" first. Any @extend should be after the import...


@import "bootstrap"


@extend


@import "bootstrap";

.MyCustomClass{
@extend .mx-2;
}



Demo: https://www.codeply.com/go/UHzJirtyju



How to extend/modify (customize) Bootstrap 4 with SASS






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV