鼠标拖拽
    
            
摘要:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div1 { width: 200px; height: 200px; background: red; position: absolu
        
阅读全文
                posted @ 
2016-03-22 11:05 
Newbie_小白
        
阅读(226) 
         
        推荐(0)     
             
            
            
    鼠标右键菜单
    
            
摘要:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> * { margin: 0; padding: 0; list-style: none; } #div1 { position: absol
        
阅读全文
                posted @ 
2016-03-22 10:13 
Newbie_小白
        
阅读(221) 
         
        推荐(0)     
             
            
            
    keydown
    
            
摘要:无标题文档 运行结果(输入文字后按Ctrl+enter则发布出去):
        
阅读全文
                posted @ 
2016-03-22 10:01 
Newbie_小白
        
阅读(441) 
         
        推荐(0)     
             
            
            
    一串跟随鼠标的DIV
    
            
摘要:div跟随鼠标移动的函数:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div1 { width: 200px; height: 200px; background: red; pos
        
阅读全文
                posted @ 
2016-03-22 09:01 
Newbie_小白
        
阅读(422) 
         
        推荐(0)     
             
            
            
    event对象和事件冒泡
    
            
摘要:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div1 { width: 400px; height: 300px; background: #CCC; display: none; 
        
阅读全文
                posted @ 
2016-03-22 08:38 
Newbie_小白
        
阅读(207) 
         
        推荐(0)     
             
            
            
    封装getByClass(JS获取class的方法封装为一个函数)
    
            
摘要:获取方法一(普通版) 获取单一的class: function getByClass(oParent, sClass) {//两个形参,第一个对象oParent 第二个样式名class var aEle = oParent.getElementsByTagName("*");//从对象里选择所有元素
        
阅读全文
                posted @ 
2016-03-12 15:35 
Newbie_小白
        
阅读(766) 
         
        推荐(0)     
             
            
            
    任意值的运动框架
    
            
摘要:function getStyle(obj, name) {//获取样式 if (obj.currentStyle) { return obj.currentStyle[name]; } else { return getComputedStyle(obj, false)[name]; }}func
        
阅读全文
                posted @ 
2016-03-12 14:46 
Newbie_小白
        
阅读(210) 
         
        推荐(0)     
             
            
            
    style,currentStyle,getComputedStyle的区别和用法
    
            
摘要:<p style="color:#f90;">这是内联样式</p> 二、嵌入样式(internal Style Sheet,内部样式):是写在HTML的head里面的,内部样式只对所在的网页有效。如: <style type="text/css"> /*这是嵌入样式*/ .stuff{color:#
        
阅读全文
                posted @ 
2016-03-12 13:29 
Newbie_小白
        
阅读(717) 
         
        推荐(0)     
             
            
            
    offset--BUG
    
            
摘要:offsetWidth所获取的宽度并不是div的实际宽度,它包括div的width、border等。 在JS函数中,可以通过obj.style.width来获取div的实际宽度,但是这种方式style只能获取行间样式,所以需要一个函数调用css中样式,代码如下:
        
阅读全文
                posted @ 
2016-03-11 15:38 
Newbie_小白
        
阅读(300) 
         
        推荐(0)     
             
            
            
    DIV的变高与变宽
    
            
摘要:代码: <!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> div { width: 200px; height: 200px; margin: 20px; float: left; back
        
阅读全文
                posted @ 
2016-03-11 15:18 
Newbie_小白
        
阅读(495) 
         
        推荐(0)     
             
            
            
    图片无缝滚动
    
            
摘要:代码: <!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> * { margin: 0; padding: 0; } #div1 { width: 712px; height: 108px; 
        
阅读全文
                posted @ 
2016-03-11 13:10 
Newbie_小白
        
阅读(253) 
         
        推荐(0)     
             
            
            
    运动——匀速运动然后停止
    
            
摘要:代码: <!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div1 { width: 100px; height: 100px; background: #ff4b46; position
        
阅读全文
                posted @ 
2016-03-11 12:58 
Newbie_小白
        
阅读(232) 
         
        推荐(0)     
             
            
            
    运动——物体运动越来越慢直到停止
    
            
摘要:代码: <!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div1 { width: 100px; height: 100px; background: #ff4b46; position
        
阅读全文
                posted @ 
2016-03-11 12:30 
Newbie_小白
        
阅读(397) 
         
        推荐(0)     
             
            
            
    运动——对联悬浮框
    
            
摘要:代码:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div { width: 100px; height: 150px; background: red; position: abso
        
阅读全文
                posted @ 
2016-03-11 12:23 
Newbie_小白
        
阅读(385) 
         
        推荐(0)     
             
            
            
    document.documentElement.scrollTop(获取滚动条位置)
    
            
摘要:要获取当前页面的滚动条纵坐标位置,用:document.documentElement.scrollTop;而不是:document.body.scrollTop;documentElement 对应的是 html 标签,而 body 对应的是 body 标签。在标准w3c下,document.bo
        
阅读全文
                posted @ 
2016-03-11 10:36 
Newbie_小白
        
阅读(12592) 
         
        推荐(1)     
             
            
            
    javascript中top、clientTop、scrollTop、offsetTop的讲解
    
            
摘要:下面结合各上图介绍一下各个属性的作用: 一.offsetTop属性: 此属性可以获取元素的上外缘距离最近采用定位父元素内壁的距离,如果父元素中没有采用定位的,则是获取上外边缘距离文档内壁的距离。所谓的定位就是position属性值为relative、absolute或者fixed。 返回值是一个整数
        
阅读全文
                posted @ 
2016-03-11 10:32 
Newbie_小白
        
阅读(759) 
         
        推荐(0)     
             
            
            
    运动——淡入淡出
    
            
摘要:一、一个DIV设置淡入淡出 代码: <!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>运动--淡入淡出</title> <!-- <link href="test_css.css" rel="stylesheet" type="tex
        
阅读全文
                posted @ 
2016-03-11 09:08 
Newbie_小白
        
阅读(309) 
         
        推荐(0)     
             
            
            
    运动——移入弹出侧边栏分享
    
            
摘要:代码:<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标题文档</title> <style> #div { width: 200px; height: 500px; background: chartreuse; positio
        
阅读全文
                posted @ 
2016-03-11 08:37 
Newbie_小白
        
阅读(305) 
         
        推荐(0)