JavaScript经典效果集锦之三

来源:互联网 发布:身份证被别人淘宝开店 编辑:程序博客网 时间:2024/05/01 14:53

JavaScript经典效果集锦之三

二十一 漂亮的表格:


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
  2.  
  3. Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>CSS Tables</title>
  8. <link href="styles.css" rel="stylesheet" type="text/css" />
  9. </head>
  10. <style type="text/css">
  11. /* CSS Document */
  12.  
  13. body {
  14.         font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  15.         color: #4f6b72;
  16.         background: #E6EAE9;
  17. }
  18.  
  19. a {
  20.         color: #c75f3e;
  21. }
  22.  
  23. #mytable {
  24.         width: 700px;
  25.         padding: 0;
  26.         margin: 0;
  27. }
  28.  
  29. caption {
  30.         padding: 0 0 5px 0;
  31.         width: 700px;         
  32.         font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  33.         text-align: right;
  34. }
  35.  
  36. th {
  37.         font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  38.         color: #4f6b72;
  39.         border-right: 1px solid #C1DAD7;
  40.         border-bottom: 1px solid #C1DAD7;
  41.         border-top: 1px solid #C1DAD7;
  42.         letter-spacing: 2px;
  43.         text-transform: uppercase;
  44.         text-align: left;
  45.         padding: 6px 6px 6px 12px;
  46.         background: #CAE8EA url(images/bg_header.jpg) no-repeat;
  47. }
  48.  
  49. th.nobg {
  50.         border-top: 0;
  51.         border-left: 0;
  52.         border-right: 1px solid #C1DAD7;
  53.         background: none;
  54. }
  55.  
  56. td {
  57.         border-right: 1px solid #C1DAD7;
  58.         border-bottom: 1px solid #C1DAD7;
  59.         background: #fff;
  60.         font-size:11px;
  61.         padding: 6px 6px 6px 12px;
  62.         color: #4f6b72;
  63. }
  64.  
  65.  
  66. td.alt {
  67.         background: #F5FAFA;
  68.         color: #797268;
  69. }
  70.  
  71. th.spec {
  72.         border-left: 1px solid #C1DAD7;
  73.         border-top: 0;
  74.         background: #fff url(images/bullet1.gif) no-repeat;
  75.         font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  76. }
  77.  
  78. th.specalt {
  79.         border-left: 1px solid #C1DAD7;
  80.         border-top: 0;
  81.         background: #f5fafa url(images/bullet2.gif) no-repeat;
  82.         font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
  83.         color: #797268;
  84. }
  85. /*---------for IE 5.x bug*/
  86. html>body td{ font-size:11px;}
  87. </style>
  88. <body>
  89. <table id="mytable" cellspacing="0" summary="The technical specifications of the Apple PowerMac
  90.  
  91. G5 series">
  92. <caption>&nbsp;</caption>
  93.   <tr>
  94.     <th scope="col" abbr="Configurations" class="nobg">Configurations</th>
  95.  
  96.     <th scope="col" abbr="Dual 1.8">Dual 1.8GHz</th>
  97.     <th scope="col" abbr="Dual 2">Dual 2GHz</th>
  98.         <th scope="col" abbr="Dual 2.5">Dual 2.5GHz</th>
  99.   </tr>
  100.   <tr>
  101.     <th scope="row" abbr="Model" class="spec">lipeng</th>
  102.     <td>M9454LL/A</td>
  103.  
  104.     <td>M9455LL/A</td>
  105.     <td>M9457LL/A</td>
  106.   </tr>
  107.   <tr>
  108.     <th scope="row" abbr="G5 Processor" class="specalt">mapabc</th>
  109.     <td class="alt">Dual 1.8GHz PowerPC G5</td>
  110.     <td class="alt">Dual 2GHz PowerPC G5</td>
  111.  
  112.     <td class="alt">Dual 2.5GHz PowerPC G5</td>
  113.   </tr>
  114.   <tr>
  115.     <th scope="row" abbr="Frontside bus" class="spec">地图名片</th>
  116.     <td>900MHz per processor</td>
  117.     <td>1GHz per processor</td>
  118.     <td>1.25GHz per processor</td>
  119.  
  120.   </tr>
  121.   <tr>
  122.     <th scope="row" abbr="L2 Cache" class="specalt">图秀卡</th>
  123.     <td class="alt">512K per processor</td>
  124.     <td class="alt">512K per processor</td>
  125.     <td class="alt">512K per processor</td>
  126.   </tr>
  127.  
  128. </table>
  129.  
  130. </body>
  131. </html>
复制代码


二十二 经典的带阴影的可拖动的浮动层


  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>MyPixbot</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <script language="JavaScript" type="text/JavaScript">
  7. <!--
  8. function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  9.   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  10.     document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  11.   else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  12. }
  13. MM_reloadPage(true);
  14.  
  15. function MM_findObj(n, d) { //v4.01
  16.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  17.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  18.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  19.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  20.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  21. }
  22.  
  23. function MM_showHideLayers() { //v6.0
  24.   var i,p,v,obj,args=MM_showHideLayers.arguments;
  25.   for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  26.     if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  27.     obj.visibility=v; }
  28. }
  29.  
  30. function
  31.  
  32. MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS
  33.  
  34. ) { //v4.01
  35.   //Copyright 1998 Macromedia, Inc. All rights reserved.
  36.   var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all,NS4=document.layers;
  37.   var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
  38.   retVal = true; if(IE && event) event.returnValue = true;
  39.   if (MM_dragLayer.arguments.length > 1) {
  40.     curDrag = MM_findObj(objName); if (!curDrag) return false;
  41.     if (!document.allLayers) { document.allLayers = new Array();
  42.       with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
  43.         for (i=0; i<allLayers.length; i++) if (allLayers[i].document &&
  44.  
  45. allLayers[i].document.layers)
  46.           with (allLayers[i].document) for (j=0; j<layers.length; j++)
  47.  
  48. allLayers[allLayers.length]=layers[j];
  49.       } else {
  50.         if (NS6) { var spns = getElementsByTagName("span"); var all =
  51.  
  52. getElementsByTagName("div");
  53.           for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position)
  54.  
  55. allLayers[allLayers.length]=spns[i];}
  56.         for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position)
  57.  
  58. allLayers[allLayers.length]=all[i];
  59.     } }
  60.     curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
  61.     curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
  62.     curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
  63.     curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
  64.     curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
  65.     curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
  66.     curLeft= (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
  67.     if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
  68.     curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
  69.     if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
  70.     curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
  71.     curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
  72.     curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
  73.     document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
  74.     if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  75.   } else {
  76.     var theEvent = ((NS)?objName.type:event.type);
  77.     if (theEvent == 'mousedown') {
  78.       var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
  79.       var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
  80.       var maxDragZ=null; document.MM_maxZ = 0;
  81.       for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
  82.         var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
  83.         if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
  84.         var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') ==
  85.  
  86. -1);
  87.         if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
  88.           var parentL=0; var parentT=0;
  89.           if (NS6) { parentLayer = aLayer.parentNode;
  90.             while (parentLayer != null && parentLayer.style.position) {            
  91.               parentL += parseInt(parentLayer.offsetLeft); parentT +=
  92.  
  93. parseInt(parentLayer.offsetTop);
  94.               parentLayer = parentLayer.parentNode;
  95.           } } else if (IE) { parentLayer = aLayer.parentElement;      
  96.             while (parentLayer != null && parentLayer.style.position) {
  97.               parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
  98.               parentLayer = parentLayer.parentElement; } }
  99.           var
  100.  
  101. tmpX=mouseX-(((NS4)?pageX:((NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
  102.           var tmpY=mouseY-(((NS4)?pageY:((NS6)?parseInt(style.top):style.pixelTop)
  103.  
  104. +parentT)+MM_hTop);
  105.           if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
  106.           var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS4)?clip.width :offsetWidth);
  107.           var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.height:offsetHeight);
  108.           if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
  109.               || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
  110.       if (curDrag) {
  111.         document.onmousemove = MM_dragLayer; if (NS4) document.captureEvents(Event.MOUSEMOVE);
  112.         curLeft = (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
  113.         curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
  114.         if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
  115.         MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
  116.         document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
  117.         if(curDrag.MM_toFront) {
  118.           eval('curDrag.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
  119.           if (!curDrag.MM_dropBack) document.MM_maxZ++; }
  120.         retVal = false; if(!NS4&&!NS6) event.returnValue = false;
  121.     } } else if (theEvent == 'mousemove') {
  122.       if (document.MM_curDrag) with (document.MM_curDrag) {
  123.         var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
  124.         var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
  125.         newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
  126.         if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
  127.         if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
  128.         if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
  129.         if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
  130.         MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
  131.         if (NS4) {left = newLeft; top = newTop;}
  132.         else if (NS6){style.left = newLeft; style.top = newTop;}
  133.         else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
  134.         if (MM_dragJS) eval(MM_dragJS);
  135.         retVal = false; if(!NS) event.returnValue = false;
  136.     } } else if (theEvent == 'mouseup') {
  137.       document.onmousemove = null;
  138.       if (NS) document.releaseEvents(Event.MOUSEMOVE);
  139.       if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
  140.       if (document.MM_curDrag) with (document.MM_curDrag) {
  141.         if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
  142.             (Math.pow(MM_targL-((NS4)?left:(NS6)?parseInt(style.left):style.pixelLeft),2)+
  143.              Math.pow(MM_targT-((NS4)?top:(NS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol)
  144.  
  145. {
  146.           if (NS4) {left = MM_targL; top = MM_targT;}
  147.           else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
  148.           else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
  149.           MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT;
  150.  
  151. }
  152.         if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
  153.         if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
  154.         retVal = false; if(!NS) event.returnValue = false; }
  155.       document.MM_curDrag = null;
  156.     }
  157.     if (NS) document.routeEvent(objName);
  158.   } return retVal;
  159. }
  160.  
  161. function loadwin(obj){
  162.         with(MM_findObj(obj))with(style){
  163.                 filters[0].apply();
  164.                 display='';
  165.                 filters[0].play();
  166.         }
  167. }
  168. function cs(captionBG,bodyBG,tableBG){
  169. oldBody=document.body;
  170.         with(oldBody){
  171.                 var newBody=cloneNode();
  172.                 style.filter='blendtrans(duration=1)';
  173.                 filters[0].apply();
  174.                 with(document.styleSheets[0]){
  175.                         with(rules[0].style){backgroundColor=captionBG;}
  176.                         with(rules[1].style){backgroundColor=bodyBG;}
  177.                         with(rules[2].style){backgroundColor=tableBG}
  178.                 }
  179.                 filters[0].play();
  180.                 setTimeout(function(){
  181.                                 if(oldBody!=null){
  182.                                         oldBody.applyElement(newBody, "inside")
  183.                                         oldBody.swapNode(newBody);
  184.                                         oldBody.removeNode(true);
  185.                                         }
  186.                                 },1500);
  187.         }
  188. }
  189. //-->
  190. </script>
  191. <style type="text/css">
  192. <!--
  193. .caption {
  194.         font-size: 9px;
  195.         color: #FFFFFF;
  196.         background-color: #00CCFF;
  197.         padding-left: 5px;
  198.         cursor: default;
  199.         font-family: "Verdana", "Arial";
  200.         border: 1px inset;
  201. }
  202. body {
  203.         background-color: #f6f6f6;
  204.         border: 1px inset;
  205.         overflow: hidden;
  206. }
  207. table {
  208.         background-color: #eeeeee;
  209. }
  210. td {
  211.         font-family: "Verdana", "Arial";
  212.         font-size: 9px;
  213.         border: 0px;
  214. }
  215. .win {
  216.         filter:BlendTrans(duration=1) DropShadow(Color=#cccccc, OffX=3, OffY=3)
  217.  
  218. alpha(opacity=90)
  219. }
  220. a {
  221.         text-decoration: none;
  222.         color: #003399;
  223. }
  224. a:hover {
  225.         color: #FF0000;
  226. }
  227. input {
  228.         font-family: "Verdana", "Arial";
  229.         font-size: 9px;
  230.         border-width: 1px;
  231. }
  232. .statusbar {
  233.         font-family: "Tahoma", "Verdana";
  234.         font-size: 9px;
  235.         color: #999999;
  236.         padding-left: 3px;
  237. }
  238. .button {
  239.         border: 1px outset;
  240.         text-align: center;
  241. }
  242. .navframe {
  243.         padding: 5px;
  244. }
  245. -->
  246. </style>
  247. </head>
  248.  
  249. <body>
  250. <div id="assist" style="position:absolute; left:15px; top:68px; width:185px;
  251.  
  252. z-index:1;display:none;" class="win"
  253.  
  254. onMouseDown="MM_dragLayer('assist','',0,0,150,18,true,false,-1,-1,-1,-1,15,68,100,'',false,'')">
  255.                 <table width="180" border="1" cellpadding="0" cellspacing="0">
  256.                                 <tr>
  257.                                                 <td class="caption">SeekAssist</td>
  258.                                                 <td width="14" align="center"><a href="#"
  259.  
  260. onclick="with(MM_findObj('assistwin').style)display=display=='none'?'':'none'">%</a></td>
  261.                                                 <td width="14" align="center"><a href="#"
  262.  
  263. onClick="MM_showHideLayers('assist','','hide')">X</a></td>
  264.                                 </tr>
  265.                                 <tr id="assistwin">
  266.                                                 <td height="100" colspan="3"
  267.  
  268. bordercolor="#eeeeee">&nbsp;</td>
  269.                                 </tr>
  270.   </table>
  271.         <br>
  272. </div>
  273. <script>loadwin('assist')</script>
  274. <div id="rank" style="position:absolute; left:15px; top:194px; width:185px;
  275.  
  276. z-index:1;display:none;" class="win"
  277.  
  278. onMouseDown="MM_dragLayer('rank','',0,0,150,18,true,false,-1,-1,-1,-1,15,194,100,'',false,'')">
  279.                 <table width="180" border="1" cellpadding="0" cellspacing="0">
  280.                                 <tr>
  281.                                                 <td class="caption">SeekRank</td>
  282.                                                 <td width="14" align="center"><a href="#"
  283.  
  284. onclick="with(MM_findObj('rankwin').style)display=display=='none'?'':'none'">%</a></td>
  285.                                                 <td width="14" align="center"><a href="#"
  286.  
  287. onClick="MM_showHideLayers('assist','','inherit','rank','','hide')">X</a></td>
  288.                                 </tr>
  289.                                 <tr id="rankwin">
  290.                                                 <td height="100" colspan="3"
  291.  
  292. bordercolor="#eeeeee">&nbsp;</td>
  293.                                 </tr>
  294.   </table>
  295.                 <br>
  296. </div>
  297. <script>setTimeout("loadwin('rank')",500)</script>
  298. <div id="mycolor" style="position:absolute; left:15px; top:320px; width:185px;
  299.  
  300. z-index:1;display:none;" class="win"
  301.  
  302. onMouseDown="MM_dragLayer('mycolor','',0,0,150,18,true,false,-1,-1,-1,-1,15,320,100,'',false,'')
  303.  
  304. ">
  305.                 <table width="180" border="1" cellpadding="0" cellspacing="0">
  306.                                 <tr>
  307.                                                 <td class="caption">MyColor</td>
  308.                                                 <td width="14" align="center"><a href="#"
  309.  
  310. onclick="with(MM_findObj('mycolorwin').style)display=display=='none'?'':'none'">%</a></td>
  311.                                                 <td width="14" align="center"><a href="#"
  312.  
  313. onClick="MM_showHideLayers('mycolor','','hide')">X</a></td>
  314.                                 </tr>
  315.                                 <tr id="mycolorwin">
  316.                                                 <td height="100" colspan="3"
  317.  
  318. bordercolor="#eeeeee"><table width="100%" border="0" cellspacing="0" cellpadding="2">
  319.                                                                 <tr>
  320.                                                                                 <td
  321.  
  322. align="center"><a href="#" onclick="cs('#00CCFF','#f6f6f6','#eeeeee')">Default</a></td>
  323.                                                                 </tr>
  324.                                                                 <tr>
  325.                                                                                 <td
  326.  
  327. align="center"><a href="#" onclick="cs('red','#eeccee','#eeddee')">StyleSheet#1</a></td>
  328.                                                                 </tr>
  329.                                                                 <tr>
  330.                                                                                 <td
  331.  
  332. align="center"><a href="#" onclick="cs('#99ccff','#eeeeee','#ccddff')">StyleSheet#2</a></td>
  333.                                                                 </tr>
  334.                                                                 <tr>
  335.                                                                                 <td
  336.  
  337. align="center"><a href="#" onclick="cs('#ff9999','#ffffff','#ffeeff')">StyleSheet#3</a></td>
  338.                                                                 </tr>
  339.                                                                 <tr>
  340.                                                                                 <td
  341.  
  342. align="center"><a href="#" onclick="cs('skyblue','#eeeeee','#99ddff')">StyleSheet#4</a></td>
  343.                                                                 </tr>
  344.                                                                 <tr>
  345.                                                                                 <td
  346.  
  347. align="center"><a href="#" onclick="cs('#009900','#eeffee','#ddffdd')">StyleSheet#5</a></td>
  348.                                                                 </tr>
  349.                                                 </table></td>
  350.                                 </tr>
  351.   </table>
  352.                 <br>
  353. </div>
  354. <script>setTimeout("loadwin('mycolor')",1000)</script>
  355. <div id="results" style="position:absolute; left:204px; top:68px; width:575px;
  356.  
  357. z-index:1;display:none;" class="win"
  358.  
  359. onMouseDown="MM_dragLayer('results','',0,0,400,18,true,false,-1,-1,-1,-1,204,68,50,'',false,'')"
  360.  
  361. >
  362.                 <table width="570" border="1" cellpadding="0" cellspacing="0">
  363.                                 <tr>
  364.                                                 <td><table width="100%" border="0"
  365.  
  366. cellspacing="0" cellpadding="0">
  367.                                                                                 <tr>
  368.                                                                                                
  369.  
  370. <td class="caption">Results</td>
  371.                                                                                                
  372.  
  373. <td width="12" class="button"><a href="#"
  374.  
  375. onClick="with(MM_findObj('resultswin').style)display=display=='none'?'':'none'">%</a></td>
  376.                                                                                                
  377.  
  378. <td width="12" class="button"><a href="#"
  379.  
  380. onClick="MM_showHideLayers('results','','inherit')">X</a></td>
  381.                                                                                 </tr>
  382.                                                 </table></td>
  383.                                 </tr>
  384.                                 <tr>
  385.                                                 <td height="20" bordercolor="#eeeeee"><input
  386.  
  387. name="url" type="text" value="http://www.google.com/search?q=ezlee" size="100">
  388.                                                 <a href="#"
  389.  
  390. onclick="mainframe.location=url.value">Search</a></td>
  391.                                 </tr>
  392.                                 <tr id="resultswin">
  393.                                                 <td height="318" valign="top"
  394.  
  395. class="navframe"><aiframe name="mainframe" id="mainframe"
  396.  
  397. src="http://www.google.com/search?q=ezlee" width="100%" height="100%" frameborder="0"
  398.  
  399. scrolling="auto"><font color="#FF0000">Welcome!</font></aiframe></td>
  400.                                 </tr>
  401.                                 <tr>
  402.                                                 <td height="14" class="statusbar">Ready!</td>
  403.                         </tr>
  404.   </table>
  405.                 <br>
  406. </div>
  407. <script>setTimeout("loadwin('results')",2000)</script>
  408. </body>
  409. </html>
复制代码

二十三 运行代码的代码


  1. <script>
  2. function Preview()
  3. {
  4.   var TestWin=open('');
  5.   TestWin.document.write(code.value);
  6.  
  7. }
  8. </script>
  9.  
  10. <textarea id=code cols=60 rows=15></textarea>
  11. <br>
  12. <button onclick=Preview() >运行</button>
复制代码

二十四 凹陷文字


  1. <div style="width:300px;padding:20px;overflow:hidden;word-wrap:break-word;word-break:break:all;
  2.  
  3. font-size:12px; line-height:18px; background-color:#eeeeee;">
  4. <font disabled>
  5. 怎么样,我凹下去了吧?<br>
  6. 你不想试试吗?<br>
  7. <a href="http://www.lenvo.cn/">www.lenvo.cn</a></font>
  8. </div>
复制代码


二十五 漂亮的仿flash菜单


  1. <style>
  2. /* 先把这个 xmenu 的样式放到css里 */
  3. .xmenu td{font-size:12px;font-family:verdana,arial;font-weight:bolder;color:#ffffff;border:1px
  4.  
  5. solid #336699;background:#336699;filter:blendtrans(duration=0.5);cursor:hand;text-align:center;}
  6. </style>
  7.  
  8. <script>
  9. /*
  10. http://lexrus.blueidea.com
  11.  
  12. 这是把事件动作绑定到菜单上的函数
  13. */
  14. function attachXMenu(objid){
  15.         var tds=objid.getElementsByTagName('td');
  16.         for(var i=0;i<tds.length;i++){
  17.                 with(tds[i]){
  18.                         onmouseover=function(){
  19.                                 with(this){
  20.                                         filters[0].apply();
  21.                                         style.background='#66CCFF'; //这是鼠标移上去时的背景颜色
  22.                                         style.border='1px solid #ffffff'; //边框
  23.                                         style.color='black'; //文字颜色
  24.                                         filters[0].play();
  25.                                 }
  26.                         }
  27.                         onmouseout=function(){
  28.                                 with(this){
  29.                                         filters[0].apply();
  30.                                         style.background='#336699'; //这是鼠标离开时的背景颜色
  31.                                         style.border='1px solid #336699'; //边框
  32.                                         style.color='#ffffff'; //文字颜色
  33.                                         filters[0].play();
  34.                                 }
  35.                         }
  36.                 }
  37.         }
  38. }
  39. </script>
  40.  
  41. <!--菜单从这里开始, 注意要把class设置成和css里相同的, 还要为它设一个id-->
  42. <table class="xmenu" id="xmenu0" width="500" cellpadding="1" cellspacing="4" border="0"
  43.  
  44. bgcolor="#336699" align="center">
  45.         <tr>
  46.                 <td><a href="http://www.lenvo.cn/">www.lenvo.cn</a></td>
  47.                 <td>Name</td>
  48.                 <td>Is</td>
  49.                 <td>LeX</td>
  50.                 <td>Rus</td>
  51.                 <td>!!!</td>
  52.         </tr>
  53. </table>
  54.  
  55. <script>attachXMenu(xmenu0); //在上面这个table结束的地方执行事件动作的绑定, 这里的这个xmenu0就是
  56.  
  57. 那个table的id</script>
  58. <br><br><br><br>
  59. <!--下面这个是竖排的-->
  60. <table class="xmenu" id="xmenu1" width="100" cellpadding="1" cellspacing="4" border="0"
  61.  
  62. bgcolor="#336699" align="center">
  63.         <tr><td>My</td></tr>
  64.         <tr><td>Name</td></tr>
  65.         <tr><td>Is</td></tr>
  66.         <tr><td>LeX</td></tr>
  67.         <tr><td>Rus</td></tr>
  68.         <tr><td>!!!</td></tr>
  69. </table>
  70. <script>attachXMenu(xmenu1);</script>
复制代码

二十六 自定义容器和字体大小


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4.  
  5.  
  6.  
  7.  
  8. <head>
  9.  
  10. <title>Home</title>
  11.  
  12. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  13. <meta name="author" content="The Man in Blue" />
  14. <meta name="robots" content="all" />
  15. <meta name="MSSmartTagsPreventParsing" content="true" />
  16. <meta name="description" content="" />
  17. <meta name="keywords" content="" />
  18.  
  19. <style type="text/css" media="all">
  20.  
  21.  
  22.  
  23.  
  24. body
  25. {
  26.         margin: 1em;
  27.         text-align: center;
  28.         font-family: Arial, Helvetica, sans-serif;
  29. }
  30.  
  31. body *
  32. {
  33.         margin: 0;
  34. }
  35.  
  36. #content
  37. {
  38.         padding: 1em;
  39.         background-color: #BBDDFF;
  40.         background-image: url(column_bg.gif);
  41.         background-repeat: repeat-y;
  42.         background-position: 30em 0;
  43.         text-align: left;
  44. }
  45.  
  46. #content p
  47. {
  48.         margin-bottom: 1em;
  49. }
  50.  
  51. #footer
  52. {
  53.         margin-top: 1em;
  54.         padding: 1em;
  55.         background-color: #0066CC;
  56.         text-align: left;
  57. }
  58.  
  59. #footer a
  60. {
  61.         color: #FFFFFF;
  62. }
  63.  
  64. #header
  65. {
  66.         margin-bottom: 1em;
  67.         padding: 1em;
  68.         background-color: #0066CC;
  69.         color: #FFFFFF;
  70.         text-align: left;
  71. }
  72.  
  73. #leftContent
  74. {
  75.         padding-right: 10em;
  76. }
  77.  
  78. #options
  79. {
  80.         margin-bottom: 1em;
  81.         text-align: right;
  82. }
  83.  
  84. #options a
  85. {
  86.         color: #000000;
  87. }
  88.  
  89. #rightContent
  90. {
  91.         float: right;
  92.         width: 8em;
  93. }
  94.  
  95. #widthContainer
  96. {
  97.         font-size: 0.8em;
  98.         width: 40em;
  99.         margin: auto;
  100. }
  101.  
  102. .clearer
  103. {
  104.         clear: both;
  105. }
  106.  
  107.  
  108.  
  109.  
  110. </style>
  111.  
  112. <script type="text/javascript">
  113. <!--
  114.  
  115.  
  116.  
  117.  
  118. function scaleWidth()
  119. {
  120.         var optimalLineLength = "35em";
  121.         var extraAccounting = "12em";
  122.         var minimumTextHeight = "10px";
  123.         var windowWidth = document.body.clientWidth;
  124.         var optimalSize = windowWidth / (parseInt(optimalLineLength) + parseInt(extraAccounting));
  125.  
  126.         if (optimalSize >= parseInt(minimumTextHeight))
  127.         {
  128.                 document.body.style.fontSize = optimalSize + "px";
  129.         }
  130.         else
  131.         {
  132.                 document.body.style.fontSize = parseInt(minimumTextHeight) + "px";
  133.         }
  134.  
  135.         return true;
  136. }
  137.  
  138.  
  139.  
  140.  
  141. function textSize(size)
  142. {
  143.         var theContainer = document.getElementById("widthContainer");
  144.         var increment = 0.1
  145.         var currentSize = parseFloat(document.getElementById("widthContainer").style.fontSize);
  146.  
  147.         if (!currentSize)
  148.         {
  149.                 currentSize = 0.8;
  150.         }
  151.  
  152.         if (size == "smaller")
  153.         {
  154.                 theContainer.style.fontSize = (currentSize - increment) + "em";
  155.         }
  156.         else
  157.         {
  158.                 theContainer.style.fontSize = (currentSize + increment) + "em";
  159.         }
  160.  
  161.         return true;
  162. }
  163.  
  164.  
  165.  
  166.  
  167. -->
  168. </script>
  169.  
  170. </head>
  171.  
  172.  
  173.  
  174.  
  175. <body onload="scaleWidth();" onresize="scaleWidth();">
  176.         <div id="widthContainer">
  177.                 <div id="options">
  178.  
  179.                         <a href="#" onclick="textSize('smaller'); return false;">Text smaller</a> |
  180.                         <a href="#" onclick="textSize('bigger'); return false;">Text bigger</a>
  181.                 </div>
  182. <!-- END options -->
  183.                 <div id="header">
  184.                         <h1>Browser-width defined font size</h1>
  185.                 </div>
  186. <!-- END header -->
  187.  
  188.                 <div id="content">
  189.                         <div id="rightContent">
  190.                                 <p>
  191.                                         Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
  192.                                 </p>
  193.                         </div>
  194. <!-- END rightContent -->
  195.                         <div id="leftContent">
  196.                                 <p>
  197.                                         Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
  198.                                 </p>
  199.  
  200.                                 <p>
  201.                                         Nulla metus. Ut sodales, tortor nec sollicitudin convallis, diam diam vulputate ligula, lobortis tincidunt urna purus at urna. Pellentesque laoreet. Nulla et dolor. Praesent vestibulum quam convallis neque. Praesent sit amet odio a dui iaculis dignissim. In vel nunc a tellus vulputate pellentesque. Maecenas bibendum. Donec mi nibh, euismod in, iaculis a, eleifend et, enim. In eget lectus vitae pede nonummy elementum. Mauris accumsan, lacus ut euismod varius, odio neque egestas quam, non aliquam velit purus et purus. Vestibulum at elit nec felis suscipit pulvinar. Suspendisse at enim quis lacus mattis condimentum. Proin arcu arcu, imperdiet vitae, aliquam non, congue id, ipsum.
  202.                                 </p>
  203.                                 <p>
  204.                                         Aliquam eu dolor nec risus luctus faucibus. Aenean condimentum, tortor in blandit cursus, dolor magna sagittis orci, vel vehicula dolor ante at lacus. Donec vel felis in enim aliquam molestie. Sed non velit id velit pulvinar consequat. Mauris luctus. Phasellus faucibus turpis nec purus. Mauris eget ante. Donec orci enim, luctus eu, posuere at, luctus quis, pede. In in lectus. Quisque blandit, ipsum eget tincidunt scelerisque, mauris ante accumsan erat, quis congue odio erat vitae diam. Donec ut felis fermentum sem viverra pulvinar. Sed neque lorem, adipiscing ut, placerat a, ornare et, dolor. Vestibulum pretium vehicula nibh. Etiam feugiat, ligula sed pulvinar fringilla, eros arcu placerat urna, nec eleifend nisl leo sit amet urna. Suspendisse quis augue ut nibh venenatis nonummy. Nunc ut augue. In fermentum, neque eget eleifend rutrum, nulla lorem fermentum massa, eu cursus lectus mi id libero.
  205.                                 </p>
  206.                                 <p>
  207.                                         Nam congue ligula quis magna. Vivamus porttitor nunc non dui. Aliquam posuere dapibus tortor. Quisque facilisis, quam in semper luctus, lacus dolor gravida massa, ultrices consectetuer risus arcu nec nibh. Nulla facilisi. In a eros id eros lobortis ultrices. Vivamus sit amet neque eu magna venenatis nonummy. Pellentesque consequat. Etiam ut ipsum. Nulla consectetuer est vel quam.
  208.                                 </p>
  209.                                 <p>
  210.  
  211.                                         Integer eu diam vitae augue sollicitudin congue. Praesent vulputate pede vel velit. Maecenas dapibus tempus lacus. Quisque lectus metus, pretium ac, mollis nec, dignissim quis, mi. Aliquam purus risus, pharetra eget, condimentum ut, blandit sit amet, leo. Suspendisse iaculis purus sed tellus. Nunc sem justo, porttitor ut, pretium eu, hendrerit eu, nunc. Vivamus sit amet neque in est venenatis faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam rhoncus, eros id ultrices facilisis, pede ligula dignissim eros, sit amet tempus risus urna sed nibh. Sed massa eros, dapibus tristique, blandit et, molestie sed, enim. Phasellus leo. Integer vestibulum volutpat enim. Duis pulvinar ligula. Pellentesque luctus velit a justo. Quisque volutpat, diam quis varius commodo, neque elit dictum tortor, quis aliquet felis risus vitae wisi. Aliquam bibendum, elit ut gravida vehicula, orci turpis auctor dolor, nec tristique tortor dolor eget ipsum.
  212.                                 </p>
  213.                         </div>
  214. <!-- END leftContent -->
  215.                         <div class="clearer">
  216.                         </div>
  217.                 </div>
  218. <!-- END content -->
  219.                 <div id="footer">
  220.                         <a href="http://www.themaninblue.com/writing/perspective/2003/12/22/">Back to the explanation</a>
  221.  
  222.                 </div>
  223.         </div>
  224. <!-- END widthContainer -->
  225. </body>
  226. </html>
复制代码
原创粉丝点击