Skip to content

Instantly share code, notes, and snippets.

Avatar

CSS魔法 cssmagic

View GitHub Profile
@cssmagic
cssmagic / survey.md
Created Sep 8, 2020
技术分享的调查问卷
View survey.md
  • 姓名 ____

  • 部门 ____

  • 本次分享/培训内容的专业性:☆☆☆☆☆

  • 本次分享/培训内容的实用性:☆☆☆☆☆

  • 本次分享/培训内容的趣味性:☆☆☆☆☆

@cssmagic
cssmagic / build-es.js
Created Dec 25, 2018
旧代码存档:用 Rollup 打包 ES6 模块
View build-es.js
'use strict'
var gulp = require('gulp')
gulp.task('mobile/build-es', function () {
var path = require('path')
var glob = require('glob')
var rollup = require('rollup').rollup
@cssmagic
cssmagic / bookmarklet.js
Last active Apr 14, 2016
脚本书签的写法(参考)
View bookmarklet.js
javascript:(function(){var l=document.createElement('link');l.setAttribute('rel','stylesheet');l.setAttribute('media','all');l.setAttribute('href','1.css');document.body.appendChild(l);var%20s%20=%20document.createElement('script');s.setAttribute('src','1.js');document.body.appendChild(s);})();
@cssmagic
cssmagic / border.styl
Last active Dec 24, 2015
`border 0` vs `border none`
View border.styl
#a
border 0 // => border 0 none
&.class1
border-style solid // => border 0 solid
&.class2
border 3px // => border 3px none
#b
border none // => border medium none
&.class1
border-style solid // => border medium solid
@cssmagic
cssmagic / ipad-viewport.html
Created Jan 22, 2015
迅速优化传统的非响应式网页在 iPad 下的表现
View ipad-viewport.html
<meta name="viewport" content="width=1024, maximum-scale=1">
@cssmagic
cssmagic / bower-path.md
Last active Aug 29, 2015
Bower 路径问题
@cssmagic
cssmagic / github-issue-format-time.js
Created Dec 12, 2014
GitHub Issue 显示标准化的时间格式
View github-issue-format-time.js
$('div[id^=issuecomment-]').each(function () {
var $header = $(this).find('.timeline-comment-header-text')
var time = $header.find('time').attr('datetime')
var date = new Date(time)
var year = date.getFullYear()
var month = format(date.getMonth() + 1)
var day = format(date.getDate())
var hour = format(date.getHours())
var min = format(date.getMinutes())
var sec = format(date.getSeconds())
@cssmagic
cssmagic / iphone-sim-ipad.html
Created Sep 9, 2013
手头只有 iPhone,想测试 iPad 怎么办?
View iphone-sim-ipad.html
<meta name="viewport" content="initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5, user-scalable=no">
@cssmagic
cssmagic / labjs-seed.js
Last active Dec 21, 2015
我自己在用的 LABjs 种子脚本,300 字节。
View labjs-seed.js
(function(d){
var src='/path/to/lab.js';
if(window.$LAB){$LAB.src=src;ini()}else{setTimeout(function(){
var e=d.createElement('script');e.onload=function(){e.onload=null;ini()};
e.src=src;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(e,s)},0)}
function ini(){
//do some $LAB stuff here...
}}(document));
@cssmagic
cssmagic / auto-redir-mobile.js
Last active Mar 11, 2018
让手机用户自动跳转到移动版网站。
View auto-redir-mobile.js
var _ua = _ua || {};
_ua.str = navigator.userAgent.toLowerCase();
_ua.isAndroid = _ua.str.indexOf('android') > -1 && _ua.str.indexOf('mobile') > -1;
_ua.isIPhone = /\(i(?:phone|pod);/.test(_ua.str);
if (_ua.isAndroid || _ua.isIPhone) {
location.href = 'http://m.example.com/';
}