Skip to content

Instantly share code, notes, and snippets.

View mattdanielbrown's full-sized avatar

Matt Daniel Brown mattdanielbrown

View GitHub Profile
@mattdanielbrown
mattdanielbrown / icon-font-cdns.html
Last active October 1, 2016 00:32
Convenient HTML stylesheet references for font icon CDNs.
<!-- Font Awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<!-- Use: -->
<!-- (fa-lg increases the icon in size realitive to container) -->
<!-- <i class="fa fa-camera-retro fa-lg"></i> fa-lg -->
<!-- <i class="fa fa-camera-retro fa-5x"></i> fa-5x -->
<!-- Linear Icon Webfont -->
<!-- <link rel="stylesheet" href="https://cdn.linearicons.com/free/1.0.0/icon-font.min.css"> -->
<!-- Use: -->
@mattdanielbrown
mattdanielbrown / disable-enable-scroll.js
Last active October 3, 2016 01:36
Grab current scroll position (including horizontal axis). Set overflow to hidden (retain previous overflow value). Scroll document to stored scroll position with scrollTo(). *** THIS REQUIRES JQUERY. ***
//
//
// This Requires jQuery
//
//
var scrollIsEnabled; // scroll state varialbe
scrollIsEnabled = true; // by default, scroll is enabled
// lock scroll position, but retain settings for later
@mattdanielbrown
mattdanielbrown / placeholder.scss
Created October 5, 2016 17:17 — forked from antsa/placeholder.scss
Placeholder mixin for Sass
// Placeholder @mixin for Sass
//
// A mixin to style placeholders in HTML5 form elements.
// Includes also a .placeholder class to be used with a polyfill e.g.
// https://github.com/mathiasbynens/jquery-placeholder
// Requires Sass 3.2.
//
// Example usage (.scss):
//
// input {

SCSS

Cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the awesome CSS extensions you've always wished you had:

  • [Nested selectors
@mattdanielbrown
mattdanielbrown / smooth-scroll-jquery.js
Created October 20, 2016 04:13
jQuery (Animated) Smooth Scrolling To Anchor Link
// $(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
@mattdanielbrown
mattdanielbrown / _trulyResponsiveFluidVerticalRhythm.scss
Created October 31, 2016 23:17
This is a more-or-less distilled SASS partial for a technique created by Mike Riethmuller. It Creates 100% responsive, fluid typography with adaptive vertical rhythm, based on the size of the viewport.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// True Responsive, Fluid, Typography & Vertical Rhythm.
// ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// - Typescale, vertical rhythm, etc.,
// - respond to change in ViewPort and adjust accordingly.
//
// This is a more-or-less distilled SASS partial for a
// technique created by Mike Riethmuller:
// * CodePen Account: http://codepen.io/MadeByMike/
@mattdanielbrown
mattdanielbrown / _quickHeadingSelectors.scss
Last active November 1, 2016 01:15
Quick heading selectors (using iterations through lists), quickly and cleanly style h1 - h6 tags, either programmatically or statically, allows use of the iteration index as a variable through the Sass functions `@each()` and `index(...)`. WARNING: Requires Bourbon Mixin Library.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// * * * * * * * * * * * * * * * * * * * * *
// * * * REQUIRES BOUBON MIXIN LIBRARY * * *
// * * * http://bourbon.io/ * * *
// * * * * * * * * * * * * * * * * * * * * *
//
//
// Quick Heading Selectors (Using Iterations Through Lists).
// ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
/*
* Quickly arrange child elements using flex.
*
* @param($direction, $distribution)
*
* $direction: Sets the axis the items are aligned to.
* [v, vertical, c, column | h, horizontal, r, row] (!optional - default = v)
* ... amounts to `flex-direction:` ...
*
* $distribution: Sets how items are arranged along main axis.
/*
* Set to fullscree size mixin
*
* @param ($exactHeight: false)
*
* $exactHeight: [true | false ] -
* Whether or not the element must only be the exact height of
* the window, and no more.
* (!Optional) default = false
* ... if false, `min-height` property is set to 100vh, so element can be taller
var touchingElement = false;
var startTime;
var startX = 0,
startY = 0;
var currentX = 0,
currentY = 0;
var isOpen = false;
var isMoving = false;
var menuWidth = 0;