Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Tutorials
CSS - Shorthand method
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sysode" data-source="post: 293984" data-attributes="member: 25453"><p>Quite often when people are asking for help, I notice in their CSS they write something like:</p><p style="margin-left: 20px">[CODE].element {</p> <p style="margin-left: 20px"> margin-top:5px;</p> <p style="margin-left: 20px"> margin-bottom:15px;</p> <p style="margin-left: 20px"> margin-right:5px;</p> <p style="margin-left: 20px"> margin-left:25px;</p> <p style="margin-left: 20px">}[/CODE]</p> <p style="margin-left: 20px"></p><p>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:</p><p style="margin-left: 20px">[CODE].element {</p> <p style="margin-left: 20px"> margin: 5px 5px 15px 25px;</p> <p style="margin-left: 20px">}[/CODE]</p><p>There is NO need to include -right, -left, -top and so on. It's all done on one line. </p><p></p><p>Here's how I remember which order to do them in: <span style="font-size: 18px"><span style="color: #ff0000">T</span>(op) <span style="color: #ff0000">R</span>(ight) ou <span style="color: #ff0000">B</span>(ottom) <span style="color: #ff0000">L</span>(eft) e = Trouble. </span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 12px">This works for any element that has -right,-left-bottom and so on. So for example, you can use padding, borders etc. </span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Not sure if I've explained it overly well, if you need any support just comment below.</span></p></blockquote><p></p>
[QUOTE="Sysode, post: 293984, member: 25453"] Quite often when people are asking for help, I notice in their CSS they write something like: [INDENT][CODE].element { margin-top:5px; margin-bottom:15px; margin-right:5px; margin-left:25px; }[/CODE] [/INDENT] 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: [INDENT][CODE].element { margin: 5px 5px 15px 25px; }[/CODE][/INDENT] 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: [SIZE=5][COLOR=#ff0000]T[/COLOR](op) [COLOR=#ff0000]R[/COLOR](ight) ou [COLOR=#ff0000]B[/COLOR](ottom) [COLOR=#ff0000]L[/COLOR](eft) e = Trouble. [/SIZE] [SIZE=3]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.[/SIZE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Tutorials
CSS - Shorthand method
Top