1 | <!DOCTYPE html> |
图片放大镜效果
1 | <!DOCTYPE html> |
苹果菜单
###模拟苹果底部的导航菜单小效果1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
*{ margin:0; padding:0;}
#div1{ width:100%; height:auto; position:absolute; bottom:0; text-align:center;}
#div1 img{ width:64px;}
</style>
<script>
window.onload = function(){
var aInput = document.getElementsByTagName('input');
var oDiv = document.getElementById('div1');
var aImg = oDiv.getElementsByTagName('img');
document.onmousemove=function(ev){
var ev=ev||event;
for(var i=0;i<aImg.length;i++){
var x = aImg[i].offsetLeft + aImg[i].offsetWidth/2;
var y = aImg[i].offsetTop + aImg[i].offsetHeight/2 + oDiv.offsetTop;
var a=ev.clientX-x;
var b=ev.clientY-y;
var c=Math.sqrt(Math.pow(a,2)+Math.pow(b,2))
var scale=1-c/300;
if(scale<0.5){
scale=0.5
}
aImg[i].style.width=scale*128+'px';
aImg[i].style.height=scale*128+'px';
aInput[i].value = 'X轴:'+x+',Y轴:' + y;
}
}
};
</script>
</head>
<body>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<div id="div1">
<img src="images/1.png">
<img src="images/2.png">
<img src="images/3.png">
<img src="images/4.png">
<img src="images/5.png">
</div>
</body>
</html>
vue-动手理解实战1
###html文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="index.css">
<script src="./vue.js"></script>
</head>
<body>
<div class="page-top">
<div class="page-content">
<h2>任务计划列表</h2>
</div>
</div>
<div class="main">
<h3 class="big-title">添加任务:</h3>
<input
placeholder="例如:吃饭睡觉打豆豆; 提示:+回车即可添加任务"
class="task-input"
type="text"
v-model="todo"
v-on:keyup.13="addTodo"
/>
<ul class="task-count" v-show="list.length">
<li>{{noCheckeLength}}个任务未完成</li>
<li class="action">
<a href="#all" :class="{active:veribliy===all}">所有任务</a>
<a href="#unfinished" :class="{active:veribliy===unfinished}">未完成的任务</a>
<a href="#finished" :class="{active:veribliy===finished}">完成的任务</a>
</li>
</ul>
<h3 class="big-title">任务列表:</h3>
<div class="tasks">
<span class="no-task-tip" v-show="!list.length">还没有添加任何任务</span>
<ul class="todo-list">
<li class="todo" :class="{completed: item.isChecked,editing: item === edtorTodos}" v-for="item in cathhash" >
<div class="view">
<input class="toggle" type="checkbox" v-model="item.isChecked" />
<label @dblclick="edtorTodo(item)">{{ item.title }}</label>
<button class="destroy" @click="deleteTodo(item)"></button>
</div>
<input
v-foucs="edtorTodos === item"
class="edit"
type="text"
v-model = "item.title"
@blur="edtorTodoed(item)"
@keyup.13="edtorTodoed(item)"
@keyup.esc="cancelTodo(item)"
/>
</li>
</ul>
</div>
</div>
<script src="./app.js"></script>
</body>
</html>
###css文件
1 | body { |
###js1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113// localstorage 存储数据
var stroe={
save(key,value){
localStorage.setItem(key,JSON.stringify(value));
},
fetch(key){
// return localStorage.getItem(JSON.parse(key));
return JSON.parse(localStorage.getItem(key)) || [];
}
}
var list = stroe.fetch("new-key");
var vm=new Vue({
el:".main",
data:{
list:list,
todo:"",
edtorTodos:'', //记录正在编辑的数据
beforeTitle:'', //记录正在编辑的数据的title
veribliy:"all"
},
watch:{
// list:function(){
// stroe.save("new-key",this.list)
// }
list:{
handler:function(){
stroe.save("new-key",this.list)
},
deep:true
}
},
computed:{
noCheckeLength:function(){
return this.list.filter(function(item){
return !item.isChecked
}).length
},
cathhash:function(){
var filted={
all:function(list){
return list;
},
unfinished:function(list){
return list.filter(function(item){
return !item.isChecked;
})
},
finished:function(list){
return list.filter(function(item){
return item.isChecked;
})
}
}
return filted[this.veribliy]?filted[this.veribliy](list):list;
}
},
methods:{
addTodo(){ //添加任务
this.list.push({
title:this.todo,
isChecked:false
});
this.todo = '';
},
deleteTodo(todo){ //删除任务
var index = this.list.indexOf(todo);
this.list.splice(index,1);
},
edtorTodo(todo){ //编辑任务
console.log(todo);
//编辑任务的时候,记录一下编辑这条任务的title,方便在取消编辑的时候重新给之前的title
this.beforeTitle = todo.title;
this.edtorTodos = todo;
},
edtorTodoed(todo){ //编辑任务成功
this.edtorTodos = '';
},
cancelTodo(todo){ //取消编辑任务
todo.title = this.beforeTitle;
this.beforeTitle = '';
//让div显示出来,input隐藏
this.edtorTodos = '';
}
},
directives:{
"foucs":{
update(el,binding){
if(binding.value){
el.focus();
}
}
}
}
});
function gethash(){
var hash=window.location.hash.slice(1);
vm.veribliy=hash;
}
gethash();
// 获取hash值
window.addEventListener("hashchange",gethash);