Skip to content

Commit d4e8c01

Browse files
Merge pull request #243 from dinesh-here/feature/sass-spacing
[Snippets] Added spacing util class for scss plugin #211
2 parents edfab6e + 1e92a33 commit d4e8c01

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

snippets/scss/utilities/spacing.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Spacing
3+
description: This SCSS snippet dynamically generates utility classes for managing spacing in a consistent and efficient manner. The classes are built using a loop, ensuring scalability and flexibility. use .mt-* for margin-top, and .pb-* for padding bottom
4+
author: dinesh-here
5+
tags: clearfix,utility,css, spacing
6+
---
7+
8+
```scss
9+
$step: 5;
10+
$start_limit: 0;
11+
$end_limit: 50;
12+
13+
@while $start_limit <= $end_limit {
14+
.mt-#{$start_limit} {
15+
margin-top: $start_limit + px;
16+
}
17+
.mb-#{$start_limit} {
18+
margin-bottom: $start_limit + px;
19+
}
20+
21+
.ml-#{$start_limit} {
22+
margin-left: $start_limit + px;
23+
}
24+
25+
.mr-#{$start_limit} {
26+
margin-right: $start_limit + px;
27+
}
28+
29+
.pt-#{$start_limit} {
30+
padding-top: $start_limit + px;
31+
}
32+
.pb-#{$start_limit} {
33+
padding-bottom: $start_limit + px;
34+
}
35+
36+
.pl-#{$start_limit} {
37+
padding-left: $start_limit + px;
38+
}
39+
40+
.pr-#{$start_limit} {
41+
padding-right: $start_limit + px;
42+
}
43+
.mx-#{$start_limit} {
44+
margin-left: $start_limit + px;
45+
margin-right: $start_limit + px;
46+
}
47+
48+
.px-#{$start_limit} {
49+
padding-left: $start_limit + px;
50+
padding-right: $start_limit + px;
51+
}
52+
53+
.my-#{$start_limit} {
54+
margin-top: $start_limit + px;
55+
margin-bottom: $start_limit + px;
56+
}
57+
58+
.py-#{$start_limit} {
59+
padding-top: $start_limit + px;
60+
padding-bottom: $start_limit + px;
61+
}
62+
63+
64+
$start_limit: $start_limit + $step;
65+
}
66+
67+
```

0 commit comments

Comments
 (0)