Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / .hide-text
Created April 10, 2012 22:15
New version of image replacement
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}​
@james2doyle
james2doyle / inline img loader
Created April 10, 2012 22:33
loading gif before inline images load
img {
background: url(loader.gif) no−repeat 50% 50%;
}
@james2doyle
james2doyle / font shorthand.css
Last active October 3, 2015 00:38
font css shorthand
/* shorthand notation for font properties */
font: [font-style] [font-variant] [font-weight] [font-size]/[line-height] [font-family];
@james2doyle
james2doyle / css buttons
Created April 10, 2012 23:12
quick buttons for prototyping
a.button {
cursor: pointer;
color: white;
font-size: 0.9em;
text-shadow: 1px 1px 0px rgba(0,0,0,0.4);
padding: 6px 20px;
border-radius: 5px;
box-shadow: inset 0px 1px rgba(255,255,255,0.3),
inset 0px -5px 20px rgba(0,0,0,0.4);
}
@james2doyle
james2doyle / Short Animation
Created April 15, 2012 18:03
Shorthand CSS3 animation
.animate {
/* name duration delay iteration-count direction fill-mode timing-function */
animation: test 1s 2s 3 alternate backwards ease;
}
@james2doyle
james2doyle / Blink Animation
Created April 15, 2012 18:08
blink css3 animation
@james2doyle
james2doyle / Media Queries Boilerplate
Created April 15, 2012 18:58
Media Queries Boilerplate for smartphones(landscape/portrait), ipad(landscape/portrait), desktop/laptops and iphone4
/*Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@james2doyle
james2doyle / Touch Pseudo Class
Created April 18, 2012 04:38
add touch style pseudo class to touch-ed elements
//remove tap-highlight-color from all in css
// a[data-active] { /* here are your styles */ }
element.addEventListener("touchstart", function (event) {
if (event.target.setAttribute) {
event.target.setAttribute("data-active", "");
}
}, true);
element.addEventListener("touchend", function (event) {
if (event.target.removeAttribute) {
@james2doyle
james2doyle / conditional content
Created April 30, 2012 03:05
Easy conditional loading of assets with css and javascript
/* THE CSS */
@media all and (min-width: 45em) {
body:after {
content: 'widescreen';
display: none;
}
}
// THE JS
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content');
@james2doyle
james2doyle / small touch detectreplace
Created April 30, 2012 17:31
Touch detection and replacement of event listeners
var isTouch = function() {
return !!('ontouchstart' in window) ? true : false;
}
if(isTouch()) {
var fireEvent = ['touchstart','touchend'];
} else {
var fireEvent = ['mousedown','mouseup'];
}
elem.addEventListener(fireEvent[0],function(){