我是一条有梦想的咸鱼

摘要: /* function getCss(obj,attr){ return window.getComputedStyle ? window.getComputedStyle(obj,null)[attr] :obj.currentStyle[attr]; } obj.style.left="354. 阅读全文
posted @ 2018-09-12 17:36 帅哥天下9 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 普通事件可以直接绑定 比如document.onmouseover=fn; 或者document.addEventListener("mouseover",fn,flase); attachEvent("onmouseover",fn); 但是DOM事件只能用addEventListener 来绑定 阅读全文
posted @ 2018-09-08 21:35 帅哥天下9 阅读(509) 评论(0) 推荐(0) 编辑
摘要: 这段代码相信大家都能看懂 如果不设置li元素的宽高 获取到的offsetTop始终是0!!! 阅读全文
posted @ 2018-09-07 13:19 帅哥天下9 阅读(2729) 评论(0) 推荐(0) 编辑
摘要: 使用方法 阅读全文
posted @ 2018-08-12 19:27 帅哥天下9 阅读(1706) 评论(0) 推荐(0) 编辑
摘要: //说到底原理上还是覆盖了 /* 只是第一次执行函数的的时候 old=dom.onload 是一个空函数 它肯定也执行了 就是 新的fn 和一个空函数 第二次执行函数的时候 第一次传入的函数fn 赋值给了old 然后执行了 新的fn 和上次的fn 原理就是新的会覆盖以前的 onload 只会执行一次 阅读全文
posted @ 2018-08-04 11:48 帅哥天下9 阅读(309) 评论(0) 推荐(0) 编辑
摘要: function $$(name){ return document.querySelectorAll(name); } var list=$$(".message ul li"); var ul=list[0].parentNode; var len=list.length; function s 阅读全文
posted @ 2018-07-31 17:02 帅哥天下9 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 不知道你们遇没遇到过这个问题 就是当你给一个元素 添加touchstart touchmove touchend 的时候 比如box 并且子元素box有被父元素overflow隐藏的部分 父元素高度 500px 子元素高度 1500px 当你鼠标没有在子元素上点击 移动 松开鼠标 (向上拉的时候) 阅读全文
posted @ 2018-07-30 15:12 帅哥天下9 阅读(687) 评论(0) 推荐(0) 编辑
摘要: 当你想要做成这种布局效果的时候 紫色框里面的内容那样 它是一个列表 li元素是块级元素 默认大小是父元素ul的宽 并且换行 如果li没有背景的话那就不用管了 可是问题来了它不但有背景 而且是根据文字自适应的宽高 这就是inline-block类型的功能了 那么想让li是inline-block 设置 阅读全文
posted @ 2018-07-30 13:49 帅哥天下9 阅读(5976) 评论(0) 推荐(0) 编辑
摘要: function show(){ document.addEventListener("click",fn,{ "passive":false, "capture":false, "once":true }); "passive" 就是告诉浏览器 我可不可以用 stopPropagation 在执行 阅读全文
posted @ 2018-07-28 20:05 帅哥天下9 阅读(756) 评论(0) 推荐(0) 编辑
摘要: 相信如果用谷歌浏览器做移动端页面的时候 用touch事件的时候应该遇到过这个东东吧 documet.addEventListener("touchstart",function(){ console.log(123); }); [Violation] Added non-passive event 阅读全文
posted @ 2018-07-27 21:26 帅哥天下9 阅读(12697) 评论(1) 推荐(0) 编辑