Skip to content

Instantly share code, notes, and snippets.

@zmmbreeze
zmmbreeze / dabblet.css
Created December 16, 2011 09:23
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
@zmmbreeze
zmmbreeze / example.css
Created August 31, 2012 13:53
example style in twitter bootstrap
.example{
position: relative;
margin: 15px 0 15px 20px;
padding: 39px 19px 14px;
background-color: white;
border: 1px solid #DDD;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
@zmmbreeze
zmmbreeze / index.html
Created October 10, 2012 03:04
Mona Lisa with pure CSS. Pointless but fun.
<div id="monalisa" />
@zmmbreeze
zmmbreeze / supportInputFile.js
Created October 28, 2012 06:09
Check input[type=file] support
var Util = {};
Util.supportInputFile = function() {
var input = document.createElement('input'),
support = false;
input.type = 'file';
// ios < 6, 会设置input为disabled
if (input.type === 'file' && !input.disabled) {
support = true;
}
this.supportInputFile = function() {
@zmmbreeze
zmmbreeze / checkImage.js
Created November 2, 2012 03:24
Using JavaScript to check if images are enabled
(function() {
var image = new Image();
image.onload = function() {
if (image.width > 0) {
document.documentElement.className += (document.documentElement.className != '') ? ' images-on' : 'images-on';
}
};
image.src = 'px.png';
}());
@zmmbreeze
zmmbreeze / insertJS.html
Last active December 15, 2015 13:39
在只能放HTML的地方插入javascript脚本
<img style="position:absolute;left:-9999px;" src="#" onerror="(function() {var s = document.createElement('script');s.src='xxx.js';var head=document.getElementsByTagName('head')[0]; head.appendChild(s);})()" />
<!-- no quote version -->
<img style=position:absolute;left:-9999px; src=# onerror=document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='xxx.js' />
@zmmbreeze
zmmbreeze / animate.js
Created April 27, 2013 10:14
Javascript simple animation.
/**
* 简易动画函数
*
* @param {HTMLElement} dom 需要执行动画的元素
* @param {Object} props 例如:{'width': 100}.
* @param {function(HTMLElement)=} opt_complete 「可选」动画结束后的回调函数
* @param {Object=} opt_options 配置
* @config {number} interval 动画间隔时间
* @config {function} easing 补间函数
* @config {number} duration 动画耗时
/* Firefox 2 */
html>/**/body .selector, x:-moz-any-link {
color:lime;
}
/* Firefox 3 */
html>/**/body .selector, x:-moz-any-link, x:default {
color:lime;
}
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);
@zmmbreeze
zmmbreeze / myScript.js
Created May 13, 2013 09:03
返回当前正在执行脚本的<script>元素
// Reliably grab my script tag
function getScript() {
var script;
if (!(script = document.currentScript)) {
script = document.getElementsByTagName("script");
script = script[script.length - 1];
}
return script;
}