// iOS微信内置浏览器UA
Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 MicroMessenger/6.0.1 NetType/WIFI
// Android微信内置浏览器UA
Mozilla/5.0 (Linux; Android 5.0; SM-N9100 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36 MicroMessenger/6.0.2.56_r958800.520 NetType/WIFI
// Android内置QQ浏览器UA
Mozilla/5.0 (Linux; Android 5.0; SM-N9100 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36 V1_AND_SQ_5.3.1_196_YYB_D QQ/5.3.1.2335 NetType/WIFI
// iOS内置QQ浏览器UA
Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 QQ/5.2.1.302 NetType/WIFI Mem/28
取消按钮、输入框、选择框等默认风格
.example {
appearance: none;
}
音频事件触发顺序
canplay -> play -> playing -> canplaythrough -> pause -> suspend -> ended
音频Sprite
audio.currentTime();
hash
<script type="text/html">
</script>
var template = document.querySelectorAll('script[type="text/html"]');
var showTemplate = function() {
var _fun = function() {
var hash = location.hash,
index = parseInt(hash.replace('#', '')) || 0;
document.body.innerHTML = template[index].innerHTML;
if (document.body.childNodes[1].nodeType == 8) {
document.title = document.body.childNodes[1].nodeValue;
}
};
_fun(); //自己执行一次
return _fun;
}();
window.addEventListener('hashchange', function() {
showTemplate();
});
工作中常用的一些技巧,放在这里,没有特意归类,请随意。
使用 sticky 属性的情况下,父元素不能有 overflow : hidden
否则会导致 sticky 失效
iOS rotate 360deg 动画,不要 0deg - 360deg
中间间隔 180deg
transition 不要用 all
针对用到的缓动属性去定义,不要一股脑的 all ,那样会带来一些不必要的麻烦
判断当前网络情况
占位
开发技巧
https://juejin.im/entry/58f6d9fb44d904006c121d2e
单词太长自动换行问题
https://juejin.im/post/58f5ead2570c3500564a5c57
右侧固定左边内容超出隐藏
占位
聊聊 input file - 文件上传
https://github.com/Monine/study/issues/5
插入音乐
计算两点的距离
CCS3 实现平形四边形
占位
宽高长图片自适应布局
icon font VS inline SVG
新趋势:使用 SVG 替代 icon font 使用 SVG 中的 Symbol 元素制作 icon
iOS 下避免吸顶元素有输入框
这会导致在弹出输入框滑动屏幕时,吸顶元素会表现的像 absolute,导致错位。
iOS sticky 吸顶
占位
input标签输入时光标不居中问题
解决方案是不要给
<input>
标签加line-height
属性反驳:不完美,对于 placeholder 属性的文字,并不居中。
设置 height 和 line-height 为相同值时,在 Android 无法垂直居中
关于 Android 微信 X5 查某个属性支持度
iOS系统微信使用的是 Safari 的内核,查支持度到 Can I use 即可。
Android 则不同,还得看 X5 的脾气,所以以下是查支持度的步骤:
iOS / Android 微信 Video 白名单与非白名单下的表现
占坑
修改 iPhone Safari 下 input disabled 的颜色
fit-content 不定宽元素居中
居中的两种旧方式:一是定宽度加
margin: 0 auto
、二是外层text-align: center;
里层display: inline-block;
DEMO 点击这里
1px边框
appearance取消默认样式
SVG实现环形进度条
实现环形进度条需要使用到SVG中的路径
<path>
在写代码之前,首先了解
<path>
有哪些参数M
表示坐标的起点
未完...
参考资料:https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths
SVG实现飘带文字
DEMO点击这里
渐变文字与镂空文字
DEMO点击这里
去掉倒数几个元素
去掉最后一个元素的某个属性
判断浏览器是否支持WebP
判断浏览器是否支持APNG
隐藏滚动条
弹性滚动
自定义滚动条
CSS3滤镜
DEMO点击这里
单行文字超出省略号
多行文字超出省略号
user-select属性
两列 左固定右内容垂直居中
方法一:高度无限制
方法二:高度有限制
DEMO1点击这里 DEMO2点击这里
calc()允许简单的加、减、乘、除运算
判断用户手机旋屏
设置input标签placeholder属性的样式
取消点击a、button、input标签后区域半透明遮罩
使用Chrome模拟手机调试时字体太大
Google Chrome默认浏览器字体最小字体为:12px,而我们手机端页面常常字体小于12px。 解决:右上角(自定义及控制) -> 设置 -> 显示高级设置 -> 网络内容(自定义字体) -> 最小字号(最小可以设置为6px)
监听CSS3动画事件
判断用户是否在手机端
图片水平镜像反转
自旋转动画
DEMO
扫光动画
DEMO
监测手机晃动事件
穿透属性
当元素叠在一起时,需要触发下层的元素时,给上层的元素加该属性。
开启GPU加速
禁用自动识别页面中的电话号码
UA
取消按钮、输入框、选择框等默认风格
音频事件触发顺序
hash
跑马灯
插入DOM节点
在此前我们常用innerHTML,推荐一个比较冷门但很实用的方法insertAdjacentHTML和insertAdjacentText