Sysode
Front-End Developer
Quite often when people are asking for help, I notice in their CSS they write something like:
Notice how you've written a specific style 4 times over? This just becomes tiring and annoying after time. This is where the shorthand method comes in, it's essentially the same but allows you to write it in one simple line. So, for example, lets copy the above code but using the shorthand method:
There is NO need to include -right, -left, -top and so on. It's all done on one line.
Here's how I remember which order to do them in: T(op) R(ight) ou B(ottom) L(eft) e = Trouble.
This works for any element that has -right,-left-bottom and so on. So for example, you can use padding, borders etc.
Not sure if I've explained it overly well, if you need any support just comment below.
Code:
.element {
margin-top:5px;
margin-bottom:15px;
margin-right:5px;
margin-left:25px;
}
Code:
.element {
margin: 5px 5px 15px 25px;
}
Here's how I remember which order to do them in: T(op) R(ight) ou B(ottom) L(eft) e = Trouble.
This works for any element that has -right,-left-bottom and so on. So for example, you can use padding, borders etc.
Not sure if I've explained it overly well, if you need any support just comment below.