Skip to content

Instantly share code, notes, and snippets.

View guyroutledge's full-sized avatar

guyroutledge

  • UK
View GitHub Profile
@guyroutledge
guyroutledge / gist:436cbfd09452d468525f
Last active August 29, 2015 14:11
CSS Layout class notes

Float Notes

Float allows us to create multi-column layouts.

We can create a two column layout by floating one container to the left and one to the right.

.main-content { float:left; width:66.67%; }
.sidebar { float:right; width:33.33%; }
---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
@guyroutledge
guyroutledge / function-calc-em.scss
Created October 18, 2013 13:54
A Sass function for turning pixels into ems
@function calc-em($target-px, $context) {
@return ($target-px / $context) * 1em;
}
@guyroutledge
guyroutledge / mixin-placeholder.scss
Created October 18, 2013 13:51
A mixin for styling placeholder text
@mixin placeholder() {
::-webkit-input-placeholder {
@content;
}
::-moz-placeholder {
@content;
}
:-moz-placeholder {
@content;
}
@guyroutledge
guyroutledge / mixin-respond-to.scss
Created October 18, 2013 13:50
A mixin for speeding up writing simple media queries
@mixin respond-to($breakpoint, $property:max-width) {
@media screen and ($property:$breakpoint) {
@content;
}
}
@guyroutledge
guyroutledge / image-replacement.scss
Created October 18, 2013 13:48
A mixin for doing text-indent image replacement
%screen-reader-text {
text-align:left;
text-indent:-9999px;
}
@mixin background-image-dimensions($image) {
width:image-width($image);
height:image-height($image);
background-image:url($image);
}
@mixin image-replacement($image) {
@guyroutledge
guyroutledge / mixin-background-image-dimensions.scss
Created October 18, 2013 13:45
A mixin for setting an elements width and height to the correct size for a background image
@mixin background-image-dimensions($image) {
width:image-width($image);
height:image-height($image);
background-image:url($image);
}
@guyroutledge
guyroutledge / mixin-selection.scss
Created October 18, 2013 13:44
Mixin for styling highlighted text
@mixin selection($background, $foreground:#fff) {
::-moz-selection { background: $background; color: $foreground; text-shadow: none; }
::selection { background: $background; color: $foreground; text-shadow: none; }
}
@guyroutledge
guyroutledge / inline-validation.js
Created September 9, 2013 15:45
Inline form validation with Gravity Forms
// if an invalid form field has been made valid,
// remove the shouty error highlighting - if a valid
// required field has been made invalid, start shouting
$('input, textarea, select').on('change', function(){
var $input = $(this);
var isRequired = $input.parents('.gfield').is('.gfield_contains_required');
var isValid = $input.is(':valid');
if ( isRequired && isValid ) {
@guyroutledge
guyroutledge / font-face-compass.scss
Created May 17, 2013 12:30
Compass font-face loop
// Generate @font-face declarations for a list of fonts
// relative path to fonts
$font-path: '../fonts/';
// the name that will be used in font-family property
$font-families: 'font1', 'font2', 'font3';
// the filename of your font without the file extension
$font-filenames: 'font1_filename', 'font2_filename', 'font3_filename';
$i: 1;