jshtml5效果,css3html5新特性
html5 拖动效果怎么在手机上实现
html5 拖动效果在手机上实现方法是调用drag和drop一系列函数实现的。
目前创新互联已为上千的企业提供了网站建设、域名、雅安服务器托管、绵阳服务器托管、企业网站设计、绍兴网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
注意:拖拽源在拖拽操作结束将得到dragend事件对象,不管操作成功与否。
举例:
定义可拖放内容
div id="columns"
div class="column" draggable="true"headerA/header/div
div class="column" draggable="true"headerB/header/div
div class="column" draggable="true"headerC/header/div
/div
2、监听拖动事件
可附加大量不同事件以监听整个拖放过程:
dragstart
drag
dragenter
dragleave
dragover
drop
dragend
a.这里是开始拖拽
function handleDragStart(e) {
this.style.opacity = '0.4'; // this / e.target is the source node.
}
var cols = document.querySelectorAll('#columns .column');
[].forEach.call(cols, function(col) {
col.addEventListener('dragstart', handleDragStart, false);
});
b.dragenter、dragover 和 dragleave 事件处理程序可用于在拖动过程中提供额外的可视化提示。例如,在拖动期间将鼠标悬停在某一列上方时,其边框可能会变成虚线。这样,用户就能知道这些列也是放置的目标区域。
怎么给html5背景加上js粒子特效
使用了particles.js
particles.js可以从github网站下载到最新的源码,网址是
使用方法非常简单
第一步,在html中引入脚本文件 particles.min.js,这个文件在下载的压缩包里可以找到
script src="particles.min.js"/script
第二步,在html中放入一个div容器,设置id为particles-js。这个一般放在所有网页元素的最后面就可以。
div id="particles-js"/div
style type="text/css"
#particles-js {
position: absolute;
top:0;
width:100%;
}
/style
第三步,设置窗口样式
style type="text/css"
#particles-js {
z-index: -1;
position: absolute;
top: 0;
width: 100%;
background: #aaa;
}/style
第四步,脚本生成粒子效果,可以单独放在一个js文件里,也可以放在script标签里。无论如何,这段脚本要出现在div容器之后。
particlesJS("particles-js", { "particles": { "number": { "value": 380, "density": { "enable": true, "value_area": 800
}
}, "color": { "value": "#ffffff"
}, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000"
}, "polygon": { "nb_sides": 5
}, "image": { "src": "img/github.svg", "width": 100, "height": 100
}
}, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false
}
}, "size": { "value": 3, "random": true, "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false
}
}, "line_linked": { "enable": true, "distance": 150, "color": "#ffffff", "opacity": 0.4, "width": 1
}, "move": { "enable": true, "speed": 6, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200
}
}
}, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": true, "mode": "grab"
}, "onclick": { "enable": true, "mode": "push"
}, "resize": true
}, "modes": { "grab": { "distance": 140, "line_linked": { "opacity": 1
}
}, "bubble": { "distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3
}, "repulse": { "distance": 200, "duration": 0.4
}, "push": { "particles_nb": 4
}, "remove": { "particles_nb": 2
}
}
}, "retina_detect": true});
在html5页面中用js怎么实现这些效果,新手求解
给你做 第一个,用的是css3和js实现的。
下面的3个都可以用js实现,如果要做的好看一点的话,可以用jquery或者其他的组件
!DOCTYPE html
html
head
style
.move
{
width:100px;
height:100px;
background:red;
position:relative;
animation-name:myfirst;
animation-duration:5s;
animation-timing-function:linear;
animation-delay:0;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:paused;
/* Firefox: */
-moz-animation-name:myfirst;
-moz-animation-duration:5s;
-moz-animation-timing-function:linear;
-moz-animation-delay:0;
-moz-animation-iteration-count:infinite;
-moz-animation-direction:alternate;
-moz-animation-play-state:paused;
/* Safari and Chrome: */
-webkit-animation-name:myfirst;
-webkit-animation-duration:5s;
-webkit-animation-timing-function:linear;
-webkit-animation-delay:0;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:paused;
/* Opera: */
-o-animation-name:myfirst;
-o-animation-duration:5s;
-o-animation-timing-function:linear;
-o-animation-delay:0;
-o-animation-iteration-count:infinite;
-o-animation-direction:alternate;
-o-animation-play-state:paused;
}
@keyframes myfirst
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-moz-keyframes myfirst /* Firefox */
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-o-keyframes myfirst /* Opera */
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
.c{
position: absolute;
width:300px;
height: 300px;
border:solid 1px red;
}
/style
/head
body
pb注释:/b本例在 Internet Explorer 中无效。/p
div class="c"
div class="move" id="move"/div
/div
/body
script
window.onload = function(){
document.getElementById("move").onclick = function(){
this.style.animationPlayState = "running";
}
}
/script
/html
文章标题:jshtml5效果,css3html5新特性
文章源于:http://cdiso.cn/article/dscgdoh.html