Skip to content

Instantly share code, notes, and snippets.

@bennyzhao
bennyzhao / device.css
Created December 9, 2013 02:49
媒体侦测不同设备尺寸
/**
* Note that the following media queries are intended to be used for the specified device or screen size
* in both portrait and landscape mode.
*
* Desktop queries are not provided since the default styles for most sites and applications typically focus
* on that for the default sites.
*
* Contributes, comments, and all that fun stuff always welcome :).
*/
@bennyzhao
bennyzhao / createDataURI.php
Created December 2, 2013 05:53
一些有用的PHP代码片段
/*
Create Data URI's
Data URI’s can be useful for embedding images into HTML/CSS/JS to save on HTTP requests.
The following function will create a Data URI based on $file for easier embedding.
*/
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
.module {
/* 一些其它样式
width: 300px;
height: 200px;*/
/* 设置成 scroll,而不要用 auto */
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
@bennyzhao
bennyzhao / disableHover.css
Created November 26, 2013 03:09
使用pointer-event:none创造60fps的滚动体验 From http://www.thecssninja.com/javascript/pointer-events-60fps
/*
* 避免子对象覆盖body的设置,因此选择器提高了属性等级另外加了important
*/
.disable-hover,
.disable-hover * {
pointer-events: none !important;
}
@bennyzhao
bennyzhao / onBeforeUnload.js
Last active December 28, 2015 06:59
Useful Dom Events
// 在用户将跳出当前页面时弹出确认框,确认框的文字会是"Please don't leave"
window.onbeforeunload = function(e) {
return "Please don't leave";
};
<!--
Using the datalist element,
HTML5 allows you to create a list of data to autocomplete a input field.
Super useful!
Here is a sample code to re-use in your own projects.
Source: http://davidwalsh.name/datalist
-->
<input name="frameworks" list="frameworks" />
setTimeout(function(){
//processing
setTimeout(arguments.callee, interval);
}, interval);
@bennyzhao
bennyzhao / @media.css
Created October 27, 2013 03:17
Awesome CSS3 Feature
/**
* @media媒体侦测
*
* 在针对不同平台或者屏幕尺寸时启用不同的css样式做到响应式布局
* 下例先设置了一套主要的css样式,随后在宽度小于900px的设备上覆盖了另一套样式
**/
/* Style the main content and the sidebar */
.container{
@bennyzhao
bennyzhao / mac.txt
Created October 24, 2013 08:49
Mac Terminal 苹果命令
// 清理LaunchPad,并重启Dock
sudo rm ~/Library/Application\ Support/Dock/*.db
sudo killall Dock
//One can make use of the following script to generate menus in an animated fashion. There are several ways of creating a menu such as list, drop down and many more.
function makeMenu(items, tags) {
// default tags
tags = tags || ['ul','li'];
var parent = tags[0];
var child = tags[1];
var item, value = '';
for (var i = 0,l = items.length; i < l; i++) {
item = items[i];