eg: jquery實現方法
你要加的樣專式為屬.active ul--li實現tab
$(".li").on("mouseover",function(){
$("li").removeClass("active");
$(this).addClass("active");
});
ok!!
㈡ 滑鼠特效代碼
尻 你會不會寫代碼呀?
<html>
<body>
就是寫在這里拉
</body>
</html>
㈢ javascript編寫的滑鼠特效代碼,在firefox中無法顯示效果!
您好,感謝您對火狐的支持
有好幾處不兼容,為您提供一個示例,簡單修專改下可以屬直接套用,與您設計的風格類似:http://www.csrcode.cn/html/txdm/sbtx/2050.htm。
您可以在火狐官方網站下載火狐瀏覽器,在火狐社區了解更多內容。希望我的回答對您有所幫助,如有疑問,歡迎繼續在本平台咨詢。
㈣ 求代碼 html css 以及 js 效果 如圖 關於滑鼠點擊
樣式可以根據實際情況布局
外部引入的可在網上下載
<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>無標題文檔</title>
<scriptlanguage="javascript"type="text/javascript"src="script/Marquee.js"></script>
</head>
<body>
<divclass="imgBox">
<divclass="div_leftfl"><ahref="javascript:void(0);"id="goL"><imgsrc="image/prev.jpg"/></a></div>
<divclass="div_centerfl"id="marquee1">
<ul>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
<li><ahref="#"><imgsrc="image/img_03.jpg"/></a></li>
</ul>
</div>
<divclass="div_rightfr"><ahref="javascript:void(0);"id="goR"><imgsrc="image/next.jpg"/></a></div>
<spanclass="clear_f"></span>
</div>
<script>
$(function(){
$('#marquee1').kxbdSuperMarquee({
distance:227,
time:3,
btnGo:{left:'#goL',right:'#goR'},
direction:'left'
});
});
</script>
</body>
</html>
㈤ javascript特效問題 頁面上有許多點一直跟隨著滑鼠指針的移動。如何實現這個這個效果.
新建html復制黏貼運行即可
<html>
<head>
<title>滑鼠跟隨效果</title>
<style type="text/css">
html {
overflow: hidden;
}
body {
position: absolute;
height: 100%;
width: 100%;
margin:0;
padding:0;
}
#screen {
background:#000;
position: absolute;
width: 100%;
height: 100%;
}
#screen span {
background: #fff;
font-size: 0;
overflow: hidden;
width: 2px;
height: 2px;
}
</style>
<script type="text/javascript">
var Follow = function () {
var $ = function (i) {return document.getElementById(i)},
addEvent = function (o, e, f) {o.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on'+e, function(){f.call(o)})},
OBJ = [], sp, rs, N = 0, m;
var init = function (id, config) {
this.config = config || {};
this.obj = $(id);
sp = this.config.speed || 4;
rs = this.config.animR || 1;
m = {x: $(id).offsetWidth * .5, y: $(id).offsetHeight * .5};
this.setXY();
this.start();
}
init.prototype = {
setXY : function () {
var _this = this;
addEvent(this.obj, 'mousemove', function (e) {
e = e || window.event;
m.x = e.clientX;
m.y = e.clientY;
})
},
start : function () {
var k = 180 / Math.PI, OO, o, _this = this, fn = this.config.fn;
OBJ[N++] = OO = new CObj(null, 0, 0);
for(var i=0;i<360;i+=20){
var O = OO;
for(var j=10; j<35; j+=1){
var x = fn(i, j).x,
y = fn(i, j).y;
OBJ[N++] = o = new CObj(O , x, y);
O = o;
}
}
setInterval(function() {
for (var i = 0; i < N; i++) OBJ[i].run();
}, 16);
}
}
var CObj = function (p, cx, cy) {
var obj = document.createElement("span");
this.css = obj.style;
this.css.position = "absolute";
this.css.left = "-1000px";
this.css.zIndex = 1000 - N;
document.getElementById("screen").appendChild(obj);
this.ddx = 0;
this.ddy = 0;
this.PX = 0;
this.PY = 0;
this.x = 0;
this.y = 0;
this.x0 = 0;
this.y0 = 0;
this.cx = cx;
this.cy = cy;
this.parent = p;
}
CObj.prototype.run = function () {
if (!this.parent) {
this.x0 = m.x;
this.y0 = m.y;
} else {
this.x0 = this.parent.x;
this.y0 = this.parent.y;
}
this.x = this.PX += (this.ddx += ((this.x0 - this.PX - this.ddx) + this.cx) / rs) / sp;
this.y = this.PY += (this.ddy += ((this.y0 - this.PY - this.ddy) + this.cy) / rs) / sp;
this.css.left = Math.round(this.x) + 'px';
this.css.top = Math.round(this.y) + 'px';
}
return init;
}();
</script></head>
<body>
<div id="screen"></div>
<script type="text/javascript">
new Follow('screen', {speed: 4,
animR : 2,
fn : function (i, j) {
return {
x : j/4*Math.cos(i),
y : j/4*Math.sin(i)
}
}})
</script></body>
</html>
㈥ 用javascript設計一個字元圍繞滑鼠特效的程序,但效果出不來,請高手指點!!!
搞定,兩處報錯:
1、document.write拼的字元串里有回車,不知道是不是貼到這格式引起的,可以忽略,下次要換行加個\號在前一行的末尾,代碼嚴格些。
2、setInterval拼成了setIntercal,直接導致undefined錯誤。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<script language="javascript">
var word=new Array(5);
word[1]="t";word[2]="a";word[3]="n";word[4]="g";word[5]="m";
for(i=1;i<=5;i++){
document.write("<div id='word"+i+"'style='width:20px;height:20px;position:absolute;font-size:10px; visibility:hidden'><font face='Forte' color='#00ff00'>"+word[i]+"</font></div>");
}
var cx=0;
var cy=0;
function locate(){
cx=window.event.x;
cy=window.event.y;
}
document.onmousemove=locate;
function show(i){
var w=eval("word"+i);
with(w.style){
visibility="visible";
s=parseInt(fontSize);
if(s>=200)
s-=100;
else if(s>90&&s<=100){
s-=85;
clearInterval("show("+(i+1)+")",20);
}
fontSize=s;
}
}
function follow(i){
var x;
if(i<4)
x=cx-50+i*10;
else
x=cx-25+i*10;
var y=cy-20+Math.floor(Math.random()*40);
w=eval("word"+i);
with(w.style)
{
left=x.toString()+"px";
top=y.toString()+"px";
}
}
function start(){
for(i=1;i<=5;i++){
val=setInterval("show(1)",20);
setInterval("follow("+i+")",100);
}
}
start();
</script>
</head>
<body>
</body>
</html>
㈦ 一段javascript,實際上是滑鼠特效,需要其於firefox並且ie中能夠顯示
每個瀏覽器就像軟體一樣,有自己獨特的表示網頁的形式,
firefox和ie,以及safari或者opera都不一樣,
其中回ie最不穩定,原答因是ie允許很多插件而其他的由於
考慮到安全問題,很多都禁用了。再者
雖然在firefox和ie中顯示html的語法很多都是相同的,
但是像特效這東東欲於兩個瀏覽器中同時兼容的話,可以,
但比較復雜!建議在ie中顯示就行了!祝好運
㈧ 急求各種網頁滑鼠特效代碼(只要代碼,不要網址)
很酷的跟隨滑鼠的三色綵帶
html>
<head>
<title>網頁特效|Linkweb.cn/Js|---很酷的跟隨滑鼠的三色綵帶</title>
</head><body bgColor=#000000>
<!--將以下代碼加入HTML的<Body></Body>之間-->
<script language="JavaScript">
<!--
var a_Colour='fff000';
var b_Colour='00ff00';
var c_Colour='ff00ff';
var Size=120;
var YDummy=new Array(),XDummy=new Array(),xpos=0,ypos=0,ThisStep=0;step=0.6;
if (document.layers){
window.captureEvents(Event.MOUSEMOVE);
function nsMouse(evnt){
xpos = window.pageYOffset+evnt.pageX+6;
ypos = window.pageYOffset+evnt.pageY+16;
}
window.onMouseMove = nsMouse;
}
else if (document.all)
{
function ieMouse(){
xpos = document.body.scrollLeft+event.x+6;
ypos = document.body.scrollTop+event.y+16;
}
document.onmousemove = ieMouse;
}
function swirl(){
for (i = 0; i < 3; i++)
{
YDummy[i]=ypos+Size*Math.sin((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4);
XDummy[i]=xpos+Size*Math.cos((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4);
}
ThisStep+=step;
setTimeout('swirl()',10);
}
var amount=10;
if (document.layers){
for (i = 0; i < amount; i++)
{
document.write('<layer name=nsa'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+a_Colour+'></layer>');
document.write('<layer name=nsb'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+b_Colour+'></layer>');
document.write('<layer name=nsc'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+c_Colour+'></layer>');
}
}
else if (document.all){
document.write('<div id="ODiv" style="position:absolute;top:0px;left:0px">'
+'<div id="IDiv" style="position:relative">');
for (i = 0; i < amount; i++)
{
document.write('<div id=x style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+a_Colour+';font-size:'+i/2+'"></div>');
document.write('<div id=y style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+b_Colour+';font-size:'+i/2+'"></div>');
document.write('<div id=z style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+c_Colour+';font-size:'+i/2+'"></div>');
}
document.write('</div></div>');
}
function prepos(){
var ntscp=document.layers;
var msie=document.all;
if (document.layers){
for (i = 0; i < amount; i++)
{
if (i < amount-1)
{
ntscp['nsa'+i].top=ntscp['nsa'+(i+1)].top;ntscp['nsa'+i].left=ntscp['nsa'+(i+1)].left;
ntscp['nsb'+i].top=ntscp['nsb'+(i+1)].top;ntscp['nsb'+i].left=ntscp['nsb'+(i+1)].left;
ntscp['nsc'+i].top=ntscp['nsc'+(i+1)].top;ntscp['nsc'+i].left=ntscp['nsc'+(i+1)].left;
}
else
{
ntscp['nsa'+i].top=YDummy[0];ntscp['nsa'+i].left=XDummy[0];
ntscp['nsb'+i].top=YDummy[1];ntscp['nsb'+i].left=XDummy[1];
ntscp['nsc'+i].top=YDummy[2];ntscp['nsc'+i].left=XDummy[2];
}
}
}
else if (document.all){
for (i = 0; i < amount; i++)
{
if (i < amount-1)
{
msie.x[i].style.top=msie.x[i+1].style.top;msie.x[i].style.left=msie.x[i+1].style.left;
msie.y[i].style.top=msie.y[i+1].style.top;msie.y[i].style.left=msie.y[i+1].style.left;
msie.z[i].style.top=msie.z[i+1].style.top;msie.z[i].style.left=msie.z[i+1].style.left;
}
else
{
msie.x[i].style.top=YDummy[0];msie.x[i].style.left=XDummy[0];
msie.y[i].style.top=YDummy[1];msie.y[i].style.left=XDummy[1];
msie.z[i].style.top=YDummy[2];msie.z[i].style.left=XDummy[2];
}
}
}
setTimeout("prepos()",10);
}
function Start(){
swirl(),prepos()
}
window.onload=Start;
// -->
</script>
</body></html>
跟隨滑鼠很逼真的彈性小球
<html>
<head>
<title>網頁特效|Linkweb.cn/Js|---跟隨滑鼠很逼真的彈性小球</title>
</head><body>
<!--將以下代碼加入HTML的<Body></Body>之間-->
<DIV id=dot0
style="HEIGHT: 16; POSITION: absolute; VISIBILITY: hidden; WIDTH: 11; left:10; top:15"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot1 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot2 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot3 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot4 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot5 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<DIV id=dot6 style="HEIGHT: 16; POSITION: absolute; WIDTH: 11; left:10; top:15"><IMG
height=11 src="images/bullet.gif" width=11> </DIV>
<SCRIPT language=JavaScript>
var nDots = 7;
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var XGRAVITY = 0;
var YGRAVITY = 50;
var RESISTANCE = 10;
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
var followmouse = true;
var dots = new Array();
init();
function init()
{
var i = 0;
for (i = 0; i < nDots; i++) {
dots[i] = new dot(i);
}
if (!isNetscape) {
}
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
startanimate();
} else {
setTimeout("startanimate()", 1000);
}
}
function dot(i)
{
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape) {
this.obj = eval("document.dot" + i);
} else {
this.obj = eval("dot" + i + ".style");
}
}
function startanimate() {
setInterval("animate()", 20);
}
function setInitPositions(dots)
{
var startloc = document.all.tags("LI");
var i = 0;
for (i = 0; i < startloc.length && i < (nDots - 1); i++) {
dots[i+1].X = startloc[i].offsetLeft
startloc[i].offsetParent.offsetLeft - DOTSIZE;
dots[i+1].Y = startloc[i].offsetTop +
startloc[i].offsetParent.offsetTop + 2*DOTSIZE;
}
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
function MoveHandler(e)
{
Xpos = e.pageX;
Ypos = e.pageY;
return true;
}
function MoveHandlerIE() {
Xpos = window.event.x + document.body.scrollLeft;
Ypos = window.event.y + document.body.scrollTop;
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y)
{
this.X = X;
this.Y = Y;
}
function springForce(i, j, spring)
{
var dx = (dots[i].X - dots[j].X);
var dy = (dots[i].Y - dots[j].Y);
var len = Math.sqrt(dx*dx + dy*dy);
if (len > SEGLEN) {
var springF = SPRINGK * (len - SEGLEN);
spring.X += (dx / len) * springF;
spring.Y += (dy / len) * springF;
}
}
function animate() {
var start = 0;
if (followmouse) {
dots[0].X = Xpos;
dots[0].Y = Ypos;
start = 1;
}
for (i = start ; i < nDots; i++ ) {
var spring = new vec(0, 0);
if (i > 0) {
springForce(i-1, i, spring);
}
if (i < (nDots - 1)) {
springForce(i+1, i, spring);
}
var resist = new vec(-dots[i].dx * RESISTANCE,
-dots[i].dy * RESISTANCE);
var accel = new vec((spring.X + resist.X)/MASS + XGRAVITY,
(spring.Y + resist.Y)/ MASS + YGRAVITY);
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
if (Math.abs(dots[i].dx) < STOPVEL &&
Math.abs(dots[i].dy) < STOPVEL &&
Math.abs(accel.X) < STOPACC &&
Math.abs(accel.Y) < STOPACC) {
dots[i].dx = 0;
dots[i].dy = 0;
}
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
var height, width;
if (isNetscape) {
height = window.innerHeight + window.pageYOffset;
width = window.innerWidth + window.pageXOffset;
} else {
height = document.body.clientHeight + document.body.scrollTop;
width = document.body.clientWidth + document.body.scrollLeft;
}
if (dots[i].Y >= height - DOTSIZE - 1) {
if (dots[i].dy > 0) {
dots[i].dy = BOUNCE * -dots[i].dy;
}
dots[i].Y = height - DOTSIZE - 1;
}
if (dots[i].X >= width - DOTSIZE) {
if (dots[i].dx > 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = width - DOTSIZE - 1;
}
if (dots[i].X < 0) {
if (dots[i].dx < 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = 0;
}
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
}
</SCRIPT>
</body></html>
這里太小了 放不了那麼多
http://www.jscode.cn/jave_mouse/29051032.htm
裡面有很多的 不想鏈接的話 就看那兩個吧
㈨ JS滑鼠滑動特效和HTML的a:hover之類的 那個好些
糾正制LZ
1.a:什麼的 叫css 超鏈接偽類
2.a:visiter後面是D,指訪問過的。
解釋:
a:link超鏈接未被訪問(默認)狀態,
a:hover滑鼠滑過超鏈接的狀態
a:visited已訪問過的鏈接的樣式(默認是紫色)
回答問題
從代碼來說,css要簡單點;
畢竟css是現成的代碼,做起來要省力許多,而且看起來方便,便於維護。
js代碼一是多,復雜,if elseif 的太多了亂 不容易恢復 不好維護。
建議LZ再重溫下css偽類的知識。
ps.在有些時候,css的代碼也可能會變得復雜js反而會簡單,請根據實際情況來定。
㈩ 請教網頁設計高手滑鼠特效代碼代碼求大神幫助
滑鼠移上去就打開頁面: 第一步:把如下代碼加入<body>區域中 <SCRIPT Language="JavaScript">function winopen () {msg=open("update.htm","NewWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,history=yes,width=400,height=260");}</SCRIPT> 第二步:把如下代碼加內入<body>區域中 <a href="鏈接地址容" onMouseOver="winopen(); return true;"><IMG SRC="shu.gif" border="0"></a> 自動跳轉的話這個度試看 <a href=" 鏈接地址" onMouseOver="指定頁面"><IMG SRC="shu.gif" border="0"></a> 不行的話加我Q吧 我這個只是理論的寫寫 沒實現過 你試試看吧
滿意請採納