Skip to content

Instantly share code, notes, and snippets.

@SteAllan
SteAllan / sprite.scss
Created August 3, 2015 10:01
Hi-res Sprite Sheet Mixin, integrating with Sass Breakpoint
@mixin sprite($icon-name, $important: '') {
@if $important != '' {
// @1x resolution screens
background-image: sprite-url($sprite-pri) !important;
background-position: sprite-position($sprite-pri, $icon-name) !important;
// @2x resolution screens
@include breakpoint($hi_res) {
background-image: sprite-url($sprite-pri--2x) !important;
@SteAllan
SteAllan / drupal-throbber.html
Created June 27, 2014 10:51
The markup for Drupal's default throbber.
<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>
// Clearfix
.clearfix, %clearfix {
&:before, &:after {
content: '';
display: table;
}
&:after {
clear: both;
}
@SteAllan
SteAllan / config.rb
Created April 17, 2014 16:44
BLESS your Sass files through compass (BLESS will need to be installed through Node first).
# Just in case the file goes over the IE limit,
# split the file into multiple.
on_stylesheet_saved do |filename|
begin
result = system('blessc',filename,'-f')
if not result
Kernel.exit(false)
else
puts "Blessed the file, so it will work in older versions of IE."
end
window.onload = function() {
// Awesome stuff goes here
}
@SteAllan
SteAllan / yes-js.js
Created February 8, 2014 18:13
Switch the JS class on the html as soon as possible. Insert this line just after the title. (http://www.456bereastreet.com/archive/201209/tell_css_that_javascript_is_available_asap/)
<script>
document.documentElement.className = document.documentElement.className.replace(/(\s|^)no-js(\s|$)/, '$1js$2');
</script>
function getScrollTop(){
if(typeof pageYOffset!= 'undefined'){
//most browsers except IE before #9
return pageYOffset;
}
else{
var B= document.body; //IE 'quirks'
var D= document.documentElement; //IE with doctype
D= (D.clientHeight)? D: B;
return D.scrollTop;
@SteAllan
SteAllan / window-alert.js
Created January 21, 2014 08:25
A JS function to alert the user when they're about to leave the page (http://css-tricks.com/use-target_blank/?utm_source=dlvr.it&utm_medium=twitter)
window.onbeforeunload = function() {
return "Two buttons will be below this message asking if user wants to stay on this page or leave.";
};
@SteAllan
SteAllan / _rem.scss
Created January 21, 2014 08:22
A Sass function to convert px values into rems, based on the px to em function in Bourbon (http://bourbon.io/docs/#px-to-em)
// Convert a px value into a rem value.
// Supply the rem value to the primary style sheet and the px fallback to the ltie9 style sheet.
@function rem($pxval) {
$val: strip-unit($pxval);
$base: strip-unit($browser-default-font-size);
@if ($ltie9 == true) {
@return $val * 1px;
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.element p {
@extend %vertical-align;