«jQuery Trickshots» by tutorialzine.com ... Reveal Code
// Loop all .fetchSize links
$('a.fetchSize').each(function(){
// Issue an AJAX HEAD request for each one
var link = this;
$.ajax({
type: 'HEAD',
url: link.href,
complete: function(xhr){
var size = humanize(xhr.getResponseHeader('Content-Length'));
// Append the filesize to each
$(link).append(' (' + type + ')');
}
});
});
function humanize(size){
var units = ['bytes','KB','MB','GB','TB','PB'];
var ord = Math.floor( Math.log(size) / Math.log(1024) );
ord = Math.min( Math.max(0,ord), units.length-1);
var s = Math.round((size / Math.pow(1024,ord))*100)/100;
return s + ' ' + units[ord];
}
// html
// First Trickshot
// This Trickshot
// Ball.png
CSS: Centering Percentage Width/Height Elements
If you know the exact width/height of an element, you can center it smack dab in the middle of its parent element easily with this classic trick: top and left set to 50% and negative margins half the width and height of the element. That's great if you know the width and height of the element you're trying to center, but what if they are percentages? ... Reveal Code
.center {
position: absolute;
left: 50%;
top: 50%;
/*
Nope =(
margin-left: -25%;
margin-top: -25%;
*/
/*
Yep!
*/
transform: translate(-50%, -50%);
/*
Not even necessary really.
e.g. Height could be left out!
*/
width: 40%;
height: 50%;
}
jQuery: close popup
скрываем всплывающее окно по клику снаружи. ... Reveal Code
$("body").click(function(e) {
if($(e.target).closest(".popup").length==0) $(".popup").css("display","none");
});
HTML: HTML5 navigation menu
HTML5 разметка меню ... Reveal Code
CSS: Table borders for ie9 & ie10
fix error with some tables in ie. ... Reveal Code
table{
border-top: 1px solid #000;
}
tr{
border-left:1px solid #000;
border-bottom:1px solid #000;
}
td{
border-right:1px solid #000;
}
CSS: Cross-Browser Inline-Block
…for very old browsers. ... Reveal Code
This is awesome
An CSS3 Trick to smooth big fonts. ... Reveal Code
h1.title{
text-shadow:-1px -1px 1px rgba(255,255,255,0.2), /* наверх и влево */
1px 1px 1px rgba(255,255,255,0.2), /* вниз и вправо */
1px 1px 1px rgba(0,0,0,0.7); /* тёмная тень */
}