How to use bootstrap 4 margin and padding properties with pixels?

Viewed 1644

I would like to use bootstrap 4 margin and padding properties with pixels instead of rems. For example, I would like the following div to have margin-left of 20 pixels:

<div class="container ml-20">Hi</div>

Is it even possible? Thanks in advance.

2 Answers

Bootstrap doesn't have anything like this. However, you can create a custom css class to handle this for you:

.ml-20 {
    margin-left: 20px;
}

Your options are limitless with how you want to set it up. You could create ml-10, ml-100 or anything you want.

There's nothing like that in Bootstrap, but in CSS, just use the code

div {
  margin-left:20px;
}
Related