Skip to content

Instantly share code, notes, and snippets.

View tripdog's full-sized avatar
💭
meditating

Tom Phillips tripdog

💭
meditating
View GitHub Profile
@sandren
sandren / tailwind.md
Last active March 20, 2024 09:37
Tailwind CSS best practices

Tailwind CSS best practices

Utility classes

  1. When writing a string of multiple utility classes, always do so in an order with meaning. The "Concentric CSS" approach works well with utility classes (i.e,. 1. positioning/visibility 2. box model 3. borders 4. backgrounds 5. typography 6. other visual adjustments). Once you establish a familiar pattern of ordering, parsing through long strings of utility classes will become much, much faster so a little more effort up front goes a long way!

  2. Always use fewer utility classes when possible. For example, use mx-2 instead of ml-2 mr-2 and don't be afraid to use the simpler p-4 lg:pt-8 instead of the longer, more complicated pt-4 lg:pt-8 pr-4 pb-4 pl-4.

  3. Prefix all utility classes that will only apply at a certain breakpoint with that breakpoint's prefix. For example, use block lg:flex lg:flex-col lg:justify-center instead of block lg:flex flex-col justify-center to make it very clear that the flexbox utilities are only applicable at the

@EastSideCode
EastSideCode / functions.php
Created February 22, 2017 13:11
WordPress Child theme functions.php
<?php
function add_parent_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
}
add_action('wp_enqueue_scripts', 'add_parent_styles');
@chered
chered / How to show or hide an element based on url using Jquery
Created November 7, 2014 00:33
How to show or hide an element based on url using Jquery
// jQuery Show / Hide Div based on URL parameter
if(window.location.href == "http://test.dev/node/1?utm_medium=adwords"){
$('.menu-818').hide();
$('.menu-900').show();
}