Home > other >  Use Bootstrap's utility API from my scss file
Use Bootstrap's utility API from my scss file

Time:05-26

The Bootstrap docs explain how to enter image description here

CodePudding user response:

@YaroslavTrach's answer is CORRECT.

But until he explained how to do it properly, I was using a dirty workaround. I'm adding it here for those who don't use scss, or don't have a node-based build environment in their project.

I added the regular mt-1 etc. classes to my custom css, and modified their names and values:

.mt-n1 { margin-top: -0.25rem !important; }
.mt-n2 { margin-top: -0.5rem !important; }
.mt-n3 { margin-top: -1rem !important; }
.mt-n4 { margin-top: -1.5rem !important; }
.mt-n5 { margin-top: -3rem !important; }

But if you do have a node-based build environment for your frontend, I recommend the accepted answer as it adds classes for every breakpoint.

  • Related