Skip to content

Instantly share code, notes, and snippets.

View stowball's full-sized avatar

Matt Stow stowball

View GitHub Profile
@stowball
stowball / 1-px-to-rem-mixin.scss
Last active December 16, 2015 00:59
Mixin to produce px fallbacks with rem duplicates
// Mixin that allows to specify arbitrary CSS properties with and output rem with pixel fallback.
// Shorthand assignments are supported too!
// Based off http://intuio.at/en/blog/an-improved-sass-rem-mixin-for-unitless-numbers/
$baseLine: 16px;
@mixin rem($property, $values)
{
// Placeholder variables
$shorthand_px: "";
$shorthand_rem: "";
@stowball
stowball / gradient.css
Last active December 16, 2015 02:19
Perfect CSS3 gradient rules, which seems impossible to create with Sass, Compass, Bourbon or any other strangely named thing
div {
background: #000;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iZzIyOSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMCUiIHkyPSIxMDAlIj48c3RvcCBzdG9wLWNvbG9yPSIjZmZmZmZmIiBvZmZzZXQ9IjAiLz48c3RvcCBzdG9wLWNvbG9yPSIjMGYwIiBvZmZzZXQ9IjAuMiIvPjxzdG9wIHN0b3AtY29sb3I9IiMwZjAiIG9mZnNldD0iMC40Ii8+PHN0b3Agc3RvcC1jb2xvcj0iIzAwMDAwMCIgb2Zmc2V0PSIxIi8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2cyMjkpIiAvPjwvc3ZnPg==);
background: -moz-linear-gradient(top, #fff 0%, #0f0 20%, #0f0 40%, #000 100%);
background: -webkit-linear-gradient(top, #fff 0%, #0f0 20%, #0f0 40%, #000 100%);
background: linear-gradient(to bottom, #fff 0%, #0f0 20%, #0f0 40%, #000 100%);
-pie-background: linear-gradient(top, #fff 0%, #0f0 20%, #0f0 40%, #000 100%);
}
Requirements. 1 mixin to produce
@stowball
stowball / all.js
Last active December 16, 2015 06:48
Pondering how the best way to selectivity include CSS and related JS
/*
If a user chooses to not include the partial for modal styles,
how can we automatically not include the modal function and its init?
Ideally, carousel and modal would be in their own file. It's like we need Sass for JS
*/
(function() {
carousel.init();
modal.init();
@stowball
stowball / nest-all.scss
Last active December 17, 2015 04:48
Sass nesting best practices. Do you group individual "sections" of a markup patten and nest that, or nest everything, more akin to matching the markup structure?
.accordion {
.js & {
display: none;
}
.js .open + & {
display: block;
}
li {
border-top: 1px solid #e2e4e6;
&:first-child {
@stowball
stowball / nth-child-examples.scss
Last active December 18, 2015 01:29
Poor man's nth-child mixin for LT IE9. It supports single (X), repeating (Xn), repeating starting from an index (Xn+Y / Xn-Y) and odd & even. View a live demo here: http://codepen.io/stowball/pen/GxlIc
.selected {
background: #000;
color: #fff;
}
.even > li:first-child {
@include nth-child(even, 'li') {
@extend .selected;
}
}
@stowball
stowball / suzi-mq.scss
Last active December 18, 2015 02:29
Suzi's Media Query mixins
@mixin media-query($value, $ltie9: true, $operator: $min, $px: false) {
@if ($operator == $max and $value < $site-width) {
// Do nothing
}
@else {
@if ($ltie9 == true) {
.ltie9 & {
@content;
}
}
@stowball
stowball / rwd-resources.md
Last active October 27, 2018 19:33
Articles and resources on responsive design approaches and workflows
@stowball
stowball / addthis.css
Created September 26, 2013 01:15
Improved "perceived" performance of AddThis
.addthis_toolbox, .addthis_toolbox iframe {
visibility: hidden !important;
}
.addthis-loaded .addthis_toolbox, .addthis-loaded .addthis_toolbox iframe {
visibility: visible !important;
}
@stowball
stowball / mime-types.txt
Created October 30, 2013 03:57
Web font MIME types
.svg image/svg+xml
.woff application/x-woff
@stowball
stowball / mq-mixins.scss
Last active December 26, 2015 23:19
Suzi Media Query Sass Mixins
// --------------------------------------------
// Default Variables
// --------------------------------------------
// The largest size for the traditional fixed-width desktop site
$site-width: 980px;
// Variables for media query operators. Saves typing
$min: unquote('min-width:');
$max: unquote('max-width:');