用說, Flash的效果大家都清楚。實際上,HTML5和JavaScript擁有很多新屬性,可以用它們來替代Flash。W3Cschool精選16個超牛逼的HTML5和JavaScript特效,看了這些特效,未來的Web發展前途無量。
1.特效:FlowerPower
創作者使用花朵作為畫刷,以貝茲曲線方式繪圖。
2.特效:Breathing Galaxies
動態變換直徑及顏色,可通過鼠標或鍵盤產生新形狀,這個效果不錯!
3.特效:Noise Field
移動鼠標可改變粒子運動,點擊可隨機生成不同粒子效果。
4.特效:HTML5 Canvas粒子效果文字動畫特效
W3Cschool利用HTML5,制造出了粒子效果文字動畫特效。只要你輸入框中輸入想要展示的文字,回車后即可在canvas上繪制出粒子效果的文字動畫,相當酷的動畫效果。
5.特效:Swirling Tentacles
三維脈沖效果,沿著脈沖線有運動的顏色漸變模塊。
6.特效:Keylight
雙擊生成兩個以后的鍵即可發出聲音,移動鍵的位置可產生不同的聲音效果。W3Cschool上面有很多這樣的教程,有興趣可以去看一下!
7.特效:Rotating Spiral
旋轉的螺旋效果,單擊可以控制開始和停止旋轉,是不是覺得高大上?
8.Blob
拖動水滴有重力效果,雙擊可以分離,小水滴碰到大水滴會合并。
9.Trail
彩色顆粒跟隨鼠標運動效果,帶尾巴淡出效果。
10.Graph Layout
一種交互的力向圖布局效果,刷新三觀。
11.Typographic Effects
使用HTML5 Canvas實現的文本特性,效果超過Flash。
12.Crazy Tentacles
移動鼠標可以進行涂鴉,點擊鼠標可以清除畫布,看著確實瘋狂。
13.Nebula
吸引眼球的粒子系統,目的是測試WebGL性能,如果滑動鼠標,可以產生絢麗效果。
14.WebGL Globe
WebGL Globe 是一個開放的地理數據可視化平臺,我們鼓勵你復制代碼,添加自己的數據,創建自己的應用。
15.Particle Playground
用鼠標和粒子進行交互,能發現不一樣的精彩。
16.Surface
使用WebGL實現的水面特效實驗,可放入一張照片,使用鼠標觸動水面會有奇特效果。
上面的HTML5和JavaScript特效,簡直趕超Flash。W3Cschool上面有很多用戶留言稱HTML5和JavaScriptit將替代Flash,不過對于這種說法,也不知道怎么去評判。畢竟這些用戶說的也是很有道理,你認為JavaScriptit會替代Flash嗎?很想知道你的答案!
公眾號:w3c技術教程
提供專業的web技術教程、手冊、工具。
言:每當過節的時候,女朋友就抱怨我總是忘記給她買花,說程序不懂浪漫,這不我準備了幾款愛心動畫特效,打算當面向她表達一下。
寓意:告白無須多么華麗的語言,一顆顆小的愛心匯聚成一顆真心,讓你的另一半感受到濃濃的愛意。
代碼難度系數★★★
新建index.html,復制以下代碼保存在瀏覽器中打開即可。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>canvas 心</title>
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
background: #000;
}
canvas {
position: absolute;
width: 100%;
height: 100%;
}</style>
</head>
<body>
<canvas id="pinkboard"></canvas>
<script>
/*
* Settings
*/
var settings={
particles: {
length: 500, // maximum amount of particles
duration: 2, // particle duration in sec
velocity: 100, // particle velocity in pixels/sec
effect: -0.75, // play with this for a nice effect
size: 30, // particle size in pixels
},
};
/*
* RequestAnimationFrame polyfill by Erik M?ller
*/
(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());
/*
* Point class
*/
var Point=(function() {
function Point(x, y) {
this.x=(typeof x !=='undefined') ? x : 0;
this.y=(typeof y !=='undefined') ? y : 0;
}
Point.prototype.clone=function() {
return new Point(this.x, this.y);
};
Point.prototype.length=function(length) {
if (typeof length=='undefined')
return Math.sqrt(this.x * this.x + this.y * this.y);
this.normalize();
this.x *=length;
this.y *=length;
return this;
};
Point.prototype.normalize=function() {
var length=this.length();
this.x /=length;
this.y /=length;
return this;
};
return Point;
})();
/*
* Particle class
*/
var Particle=(function() {
function Particle() {
this.position=new Point();
this.velocity=new Point();
this.acceleration=new Point();
this.age=0;
}
Particle.prototype.initialize=function(x, y, dx, dy) {
this.position.x=x;
this.position.y=y;
this.velocity.x=dx;
this.velocity.y=dy;
this.acceleration.x=dx * settings.particles.effect;
this.acceleration.y=dy * settings.particles.effect;
this.age=0;
};
Particle.prototype.update=function(deltaTime) {
this.position.x +=this.velocity.x * deltaTime;
this.position.y +=this.velocity.y * deltaTime;
this.velocity.x +=this.acceleration.x * deltaTime;
this.velocity.y +=this.acceleration.y * deltaTime;
this.age +=deltaTime;
};
Particle.prototype.draw=function(context, image) {
function ease(t) {
return (--t) * t * t + 1;
}
var size=image.width * ease(this.age / settings.particles.duration);
context.globalAlpha=1 - this.age / settings.particles.duration;
context.drawImage(image, this.position.x - size / 2, this.position.y - size / 2, size, size);
};
return Particle;
})();
/*
* ParticlePool class
*/
var ParticlePool=(function() {
var particles,
firstActive=0,
firstFree=0,
duration=settings.particles.duration;
function ParticlePool(length) {
// create and populate particle pool
particles=new Array(length);
for (var i=0; i < particles.length; i++)
particles[i]=new Particle();
}
ParticlePool.prototype.add=function(x, y, dx, dy) {
particles[firstFree].initialize(x, y, dx, dy);
// handle circular queue
firstFree++;
if (firstFree==particles.length) firstFree=0;
if (firstActive==firstFree ) firstActive++;
if (firstActive==particles.length) firstActive=0;
};
ParticlePool.prototype.update=function(deltaTime) {
var i;
// update active particles
if (firstActive < firstFree) {
for (i=firstActive; i < firstFree; i++)
particles[i].update(deltaTime);
}
if (firstFree < firstActive) {
for (i=firstActive; i < particles.length; i++)
particles[i].update(deltaTime);
for (i=0; i < firstFree; i++)
particles[i].update(deltaTime);
}
// remove inactive particles
while (particles[firstActive].age >=duration && firstActive !=firstFree) {
firstActive++;
if (firstActive==particles.length) firstActive=0;
}
};
ParticlePool.prototype.draw=function(context, image) {
// draw active particles
if (firstActive < firstFree) {
for (i=firstActive; i < firstFree; i++)
particles[i].draw(context, image);
}
if (firstFree < firstActive) {
for (i=firstActive; i < particles.length; i++)
particles[i].draw(context, image);
for (i=0; i < firstFree; i++)
particles[i].draw(context, image);
}
};
return ParticlePool;
})();
/*
* Putting it all together
*/
(function(canvas) {
var context=canvas.getContext('2d'),
particles=new ParticlePool(settings.particles.length),
particleRate=settings.particles.length / settings.particles.duration, // particles/sec
time;
// get point on heart with -PI <=t <=PI
function pointOnHeart(t) {
return new Point(
160 * Math.pow(Math.sin(t), 3),
130 * Math.cos(t) - 50 * Math.cos(2 * t) - 20 * Math.cos(3 * t) - 10 * Math.cos(4 * t) + 25
);
}
// creating the particle image using a dummy canvas
var image=(function() {
var canvas=document.createElement('canvas'),
context=canvas.getContext('2d');
canvas.width=settings.particles.size;
canvas.height=settings.particles.size;
// helper function to create the path
function to(t) {
var point=pointOnHeart(t);
point.x=settings.particles.size / 2 + point.x * settings.particles.size / 350;
point.y=settings.particles.size / 2 - point.y * settings.particles.size / 350;
return point;
}
// create the path
context.beginPath();
var t=-Math.PI;
var point=to(t);
context.moveTo(point.x, point.y);
while (t < Math.PI) {
t +=0.01; // baby steps!
point=to(t);
context.lineTo(point.x, point.y);
}
context.closePath();
// create the fill
context.fillStyle='#ea80b0';
context.fill();
// create the image
var image=new Image();
image.src=canvas.toDataURL();
return image;
})();
// render that thing!
function render() {
// next animation frame
requestAnimationFrame(render);
// update time
var newTime=new Date().getTime() / 1000,
deltaTime=newTime - (time || newTime);
time=newTime;
// clear canvas
context.clearRect(0, 0, canvas.width, canvas.height);
// create new particles
var amount=particleRate * deltaTime;
for (var i=0; i < amount; i++) {
var pos=pointOnHeart(Math.PI - 2 * Math.PI * Math.random());
var dir=pos.clone().length(settings.particles.velocity);
particles.add(canvas.width / 2 + pos.x, canvas.height / 2 - pos.y, dir.x, -dir.y);
}
// update and draw particles
particles.update(deltaTime);
particles.draw(context, image);
}
// handle (re-)sizing of the canvas
function onResize() {
canvas.width=canvas.clientWidth;
canvas.height=canvas.clientHeight;
}
window.onresize=onResize;
// delay rendering bootstrap
setTimeout(function() {
onResize();
render();
}, 10);
})(document.getElementById('pinkboard'));</script>
</body>
</html>
寓意:將想說的話打開一顆顆的愛心氣球上,隨著氣球不斷的升空,讓整個氛圍可更加地纏綿,看到此處可以有感動的淚水。
代碼難度系數★★★
新建index.html,復制以下代碼保存在瀏覽器中打開即可。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>情人節快樂:)</title>
<style>
canvas {
position: absolute;
top: 0;
left: 0;
}</style>
</head>
<body>
<canvas id=c></canvas>
<script>
var w=c.width=window.innerWidth,
h=c.height=window.innerHeight,
ctx=c.getContext( '2d' ),
opts={
phrases: [ "Don't die\nit's not hard", "You're the Best", "Every day,\nYou're beautiful", "Every occasion,\nYou're clever", "A world without You?\nNah", "Keep kicking ass", "You're better than them,\nwhoever they are", "You're just amazing", "You are,\ntherefore I am", "Nothing better than You \ncould have happened to the world" ],
balloons: 10,
baseVelY: -1,
addedVelY: -1,
baseVelX: -.25,
addedVelX: .5,
baseSize: 20,
addedSize: 10,
baseSizeAdder: 2,
addedSizeAdder: 2,
baseIncrementer: .01,
addedIncrementer: .03,
baseHue: -10,
addedHue: 30,
font: '15px Verdana'
},
cycle=0,
balloons=[];
ctx.font=opts.font;
function Balloon(){
this.reset();
}
Balloon.prototype.reset=function(){
this.size=opts.baseSize + opts.addedSize * Math.random();
this.sizeAdder=opts.baseSizeAdder + opts.addedSizeAdder * Math.random();
this.incrementer=opts.baseIncrementer + opts.addedIncrementer * Math.random();
this.tick=0;
this.x=Math.random() * w;
this.y=h + this.size;
this.vx=opts.baseVelX + opts.addedVelX * Math.random();
this.vy=opts.baseVelY + opts.addedVelY * Math.random();
this.color='hsla(hue,70%,60%,.8)'.replace( 'hue', opts.baseHue + opts.addedHue * Math.random() );
this.phrase=opts.phrases[ ++cycle % opts.phrases.length ].split( '\n' );
this.lengths=[];
for( var i=0; i < this.phrase.length; ++i )
this.lengths.push( -ctx.measureText( this.phrase[ i ] ).width / 2 );
}
Balloon.prototype.step=function(){
this.tick +=this.incrementer;
this.x +=this.vx;
this.y +=this.vy;
var size=this.size + this.sizeAdder * Math.sin( this.tick );
ctx.lineWidth=size / 40;
ctx.strokeStyle='#eee';
ctx.beginPath();
ctx.moveTo( this.x, this.y - 2 );
ctx.lineTo( this.x, this.y + size );
ctx.stroke();
ctx.fillStyle=this.color;
ctx.translate( this.x, this.y );
ctx.rotate( Math.PI / 4 );
//ctx.fillRect( -size / 2, -size / 2, size / 2, size / 2 );
ctx.beginPath();
ctx.moveTo( 0, 0 );
ctx.arc( -size / 2, -size / 2 + size / 4, size / 4, Math.PI / 2, Math.PI * 3 / 2 );
ctx.arc( -size / 2 + size / 4, -size / 2, size / 4, Math.PI, Math.PI * 2 );
ctx.lineTo( 0, 0 );
ctx.fill();
ctx.rotate( -Math.PI / 4 );
ctx.translate( -this.x, -this.y );
ctx.translate( this.x, this.y + size + 15 );
ctx.scale( size / this.size, size / this.size );
ctx.fillStyle='#eee';
for( var i=0; i < this.phrase.length; ++i )
ctx.fillText( this.phrase[ i ], this.lengths[ i ], i * 15 );
ctx.scale( this.size / size, this.size / size );
ctx.translate( -this.x, -( this.y + size + 15 ) );
if( this.y < -size * 3 )
this.reset();
}
function anim(){
window.requestAnimationFrame( anim );
ctx.fillStyle='#222';
ctx.fillRect( 0, 0, w, h );
if( balloons.length < opts.balloons && Math.random() < .01 )
balloons.push( new Balloon );
for( var i=0; i < balloons.length; ++i )
balloons[ i ].step();
}
anim();</script>
</body>
</html>
寓意:天空中下起了愛心雨,襯托的房間變得溫暖,也讓整個場景都變得溫馨無比,想必此時可以有一個大大的擁抱。
代碼難度系數★★★
代碼有image、js和html,所以不好貼出來,有需要的朋友直接問我要吧。
總結:程序員的工作本身就很枯燥,特定找了幾個好看的特效拿出來和大家分享,希望大家能夠快樂每一天,上述代碼親測可用,歡迎點贊收藏。
《完》
大家如果喜歡的話麻煩點贊、關注、轉發,謝謝大家。
<script src="https://lf6-cdn-tos.bytescm.com/obj/cdn-static-resource/tt_player/tt.player.js?v=20160723"></script>
<!DOCTYPE HTML>
<html>
<head>
<title>文內鏈接</title>
<style>
a:hover
{
background-color:yellow;
}
</style>
</head>
<body >
<div style="width:50%;margin:auto;"><!--使頁面居中顯示,并展視窗50%寬度-->
<div style="position:fixed; top:0px;"><!--使導航菜單懸停在頂端-->
<a style="margin: 0px 30px 0px 10px;" href="#chapter1">試飛進程</a>
<a style="margin: 0px 30px 0px 0px;" href="#chapter2">研制情況</a>
<a style="margin: 0px 30px 0px 0px;" href="#chapter3">服役動態</a>
<a style="margin: 0px 30px 0px 0px;"href="#chapter4">總體評價</a>
</div><!--使導航菜單懸停在頂端(結尾)-->
<div style="margin:30px 0px 0px 0px;width:600px;overflow:hidden;"><!--小div套大div隱藏滾動條-->
<div style="margin:0px 0px 0px 8px;width:610px; height:530px; overflow-y:scroll;overflow-x:hidden;" >
<p><!--小div-->
<h2><a id="chapter1" >試飛進程</a></h2>
殲-20隱形戰斗機首架技術驗證機于2011年1月11日中午12時50分左右進行首次升空飛行測試,13時08分成功著陸,歷時18分鐘。<br>
整個首飛過程在殲-10S戰斗教練機陪伴下完成 。
2016年10月28日,首次發布“空軍試飛員將駕殲-20飛機亮相中國航展”后,還陸續發布了“殲-20戰機列裝空軍作戰部隊”“空軍殲-20戰機首次開展海上方向實戰化訓練”等。
<h2><a id="chapter2">研制情況</a></h2>
在2016年11月1日,第十一屆珠海航展,殲-20首次進行空中飛行展示。兩架殲-20做了公開飛行,不僅在現場引起轟動,也立刻被西方媒體大量報道。殲-20是中國現代空中力量的代表作,也進入了世界最先進的第五代戰斗機行列,它是中國國防能力高速發展的一個象征。<br>
2018年11月11日,第十二屆中國航展在珠海迎來“高光時刻”:殲-20戰機在公開飛行展示中掛彈開倉,震撼獻禮人民空軍成立69周年紀念日。 <br>
2019年10月13日,慶祝人民空軍成立70周年航空開放活動新聞發布上,空軍新聞發言人申進科大校介紹殲-20戰機列陣人民空軍“王牌部隊”
<h2><a id="chapter3" >服役動態</a></h2>
2017年3月9日,中央電視臺報道殲-20戰斗機正式進入空軍序列。<br>
2017年3月13日,《中國日報》發布消息稱,中國自主研制的殲-20近期將裝配國產發動機。<br>
2017年7月30日,殲-20三機編隊參加在朱日和舉行的慶祝中國人民解放軍成立90周年閱兵。殲擊機梯隊飛來,3架殲-20隱形戰斗機以楔形編隊的形式在天空中飛過。<br>
2017年9月28日,在中國國防部行記者會上,國防部新聞發言人吳謙大校介紹殲-20飛機已經列裝部隊。<br>
2017年11月10日上午,中國空軍發言人申進科大校表示,殲-20 列裝部隊后,已經開展編隊訓練。<br>
2018年2月9日,中國空軍新聞發言人申進科大校發布消息,殲-20開始列裝空軍作戰部隊。<br>
2018年10月30日,中國空軍4架殲-20隱形戰斗機現身珠海金灣機場上空。<br>
2019年10月1日,殲-20現身慶祝中華人民共和國成立70周年閱兵式;閱兵中,殲-20與殲-16、殲-10C三型飛機分別以5機楔隊組成戰斗隊形接受檢閱;該三款殲擊機被譽為中國空軍殲擊機家族的“三劍客”,是未來聯合作戰的骨干力量
<h2><a id="chapter4" >總體評價</a></h2>
殲-20是眼下亞洲區域最先進的戰機,這讓中國空軍在面對日本、韓國與印度等國家的空軍時占有顯著優勢。外媒將殲-20與其他國家戰機進行了對比。俄羅斯蘇霍伊蘇-57戰斗機由于研制進度幾度推遲,尚未正式交付入役;美國F-35戰斗機也多次出現飛機供氧不足的問題,大面積停飛,出口受阻;韓國KF-X隱形戰機先是被爆出因掌握不了關鍵技術而被迫降成四代半戰機的情況,后又傳出了合作方印尼打算撤資并已告知韓國的消息。因此,中國殲-20戰機成為亞太區域領跑的優勢戰機。<br>
中國空軍正向全疆域作戰的現代化戰略性軍種邁進,成為有效塑造態勢、管控危機、遏制戰爭、打贏戰爭的重要力量。殲-20戰機列裝空軍作戰部隊,將進一步提升空軍綜合作戰能力,有助于空軍更好的肩負起維護國家主權、安全和領土完整的神圣使命。<br>
殲20是我國自主研制的第五代戰斗機,它的研制實現了既定的四大目標——打造跨代新機、引領技術發展、創新研發體系、建設卓越團隊。打造跨代新機,是按照性能、技術和進度要求,研制開發我國自己的新一代隱身戰斗機。引領技術發展,指通過自主創新實現強軍興軍的目標。殲20在態勢感知、信息對抗、協同作戰等多方面取得了突破,這是中國航空工業從跟跑到并跑,再到領跑的必由之路。創新研發體系,是指建設最先進的飛機研制條件和研制流程。通過一大批大國重器的研制,我們建立了具有我國特色的數字化研發體系。建設卓越團隊,是指通過型號研制,錘煉一支愛黨愛國的研制隊伍,這些擁有報國情懷、創新精神的優秀青年是航空事業未來發展的生力軍。未來,我們將在戰斗機的機械化、信息化、智能化發展征程上不斷前行。
</p>
<img border="0" src="img/image1.jpg" usemap="#map" / >
<map name="map" id="map">
<area shape="poly" coords="142,62,186,175,246,236,243,298,263,323,396,338,478,313,516,246,496,224,320,158,348,142,336,129,232,108" href="https://www.zhihu.com/question/284642168" / title="殲20氣動外形分析"><!--必須保證畫面尺寸與頁面顯示尺寸一致!-->
</map>
</div><!--小div(結尾)-->
</div><!--小div套大div隱藏滾動條(結尾)-->
</div><!--使頁面居中顯示,并展視窗50%寬度(結尾)-->
</body>
</html>
1.頁面內容居中顯示方法
2.導航欄懸停頂端方法
3.鼠標滑過導航標題或鏈接時改變背景色提示
3.隱藏滾動條方法
4.圖片區域鏈接
大家結合代碼和技術解析,先自行分析一下每段代碼的作用,以及它們之間的前后關系。這一步練習對培養代碼閱讀能力很有好處,希望大家可以先自行閱讀分析。
下一次,我會逐步演示“頁面制作技術解析”中的五個步驟以及一些注意事項。
使用碎片時間,學習完整知識!關注大魚師兄,一起精研技藝。
HTML序章(學習目的、對象、基本概念)——零基礎自學網頁制作
HTML是什么?——零基礎自學網頁制作
第一個HTML頁面如何寫?——零基礎自學網頁制作
HTML頁面中head標簽有啥用?——零基礎自學網頁制作
初識meta標簽與SEO——零基礎自學網頁制作
HTML中的元素使用方法1——零基礎自學網頁制作
HTML中的元素使用方法2——零基礎自學網頁制作
HTML元素中的屬性1——零基礎自學網頁制作
HTML元素中的屬性2(路徑詳解)——零基礎自學網頁制作
使用HTML添加表格1(基本元素)——零基礎自學網頁制作
使用HTML添加表格2(表格頭部與腳部)——零基礎自學網頁制作
使用HTML添加表格3(間距與顏色)——零基礎自學網頁制作
使用HTML添加表格4(行顏色與表格嵌套)——零基礎自學網頁制作
16進制顏色表示與RGB色彩模型——零基礎自學網頁制作
HTML中的塊級元素與內聯元素——零基礎自學網頁制作
初識HTML中的<div>塊元素——零基礎自學網頁制作
在HTML頁面中嵌入其他頁面的方法——零基礎自學網頁制作
封閉在家學網頁制作!為頁面嵌入PDF文件——零基礎自學網頁制作
HTML表單元素初識1——零基礎自學網頁制作
HTML表單元素初識2——零基礎自學網頁制作
HTML表單3(下拉列表、多行文字輸入)——零基礎自學網頁制作
HTML表單4(form的action、method屬性)——零基礎自學網頁制作
HTML列表制作講解——零基礎自學網頁制作
為HTML頁面添加視頻、音頻的方法——零基礎自學網頁制作
音視頻格式轉換神器與html視頻元素加字幕——零基礎自學網頁制作
HTML中使用<a>標簽實現文本內鏈接——零基礎自學網頁制作
HTML中的圖片區域鏈接方法詳解——零基礎自學網頁制作
HTML圖片區域鏈接注意事項與Gimp基本用法——零基礎自學網頁制作
用HTML制作一個簡單頁面(詳解)——零基礎自學網頁制作(完結篇)
*請認真填寫需求信息,我們會在24小時內與您取得聯系。