Skip to content

Instantly share code, notes, and snippets.

View djanix's full-sized avatar

Janic Beauchemin djanix

View GitHub Profile
@djanix
djanix / css -> clearfix
Last active October 2, 2015 00:28
css -> Clear after a float element for all browser and without adding aditionnal markup in the html
.clearfix:before, .clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
@djanix
djanix / css -> inline-block fix
Last active October 2, 2015 00:28
css -> Inline-block fix for ie6/ie7
.yourClass {
display: inline-block;
*display: inline;
zoom: 1;
}
@djanix
djanix / Label + input vertical align display fix for all browsers
Created March 21, 2012 14:38
css -> label and input vertical align
/*---------------------------------------------------------------------------
* Label + input display fix
* Put the input + text inside the label to make it works correctly
*--------------------------------------------------------------------------*/
label {
display: block;
padding-left: 15px;
text-indent: -15px;
}
@djanix
djanix / js -> vertical align
Created April 13, 2012 17:16
js -> vertical align
verticalAlign(yourElement);
function verticalAlign(el) {
var height = el.height();
var parentHeight = el.parent().height();
var padding = (parentHeight - height) / 2;
el.css('padding-top', padding);
}
@djanix
djanix / js -> convert percent to number
Created April 13, 2012 17:17
js -> convert percent to number
function convertPercentToNumber(el) {
if (el.charAt(el.length-1) == '%') {
return el.slice(0, -1)/100*duration;
} else {
return el;
}
}
@djanix
djanix / js -> parse xml file
Created April 13, 2012 17:23
js -> parse xml file
/////////////////////////////////////////////////////
XML DOCUMENT EXAMPLE
/////////////////////////////////////////////////////
<?xml version="1.0"?>
<items>
<item>
<headline>title</headline>
<description>text</description>
<image>content_logo.png</image>
</item>
@djanix
djanix / css -> force text on one line
Last active January 14, 2016 19:44
css -> ellipsis
p {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
@djanix
djanix / css -> mobile font size
Last active December 12, 2015 04:29
Font size for mobile devices
body {
font-size: 62.5%; /* resets the page font size */
}
p {
font-size: 0.8em; /* equals 8px */
font-size: 1.0em; /* equals 10px */
font-size: 1.6em; /* equals 16px */
font-size: 2.0em; /* equals 20px */
}
@djanix
djanix / responsive -> img swap
Last active December 13, 2015 21:58
mobile -> swap img mobile vs tablet vs desktop
<img src="" data-src-desktop="pathTo/imgName.jpg" data-src-tablet="pathTo/imgName_tablet.jpg" data-src-mobile="pathTo/imgName_tablet.jpg" alt="" />
@djanix
djanix / less -> var in bg-image path
Created March 19, 2013 18:33
Hot to add a var in a background-image css rule in less
@image-path: "../path/to/img";
.item {
background: url("@{image-path}/image.png") center center no-repeat;
}