Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4021278
  • 博文数量: 272
  • 博客积分: 7846
  • 博客等级: 少将
  • 技术积分: 6476
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-25 16:27
文章分类

全部博文(272)

分类: 系统运维

2011-06-20 23:38:54

先看图吧,这就是最终效果:
在默认状态下,或点击红色按钮后:

在点击绿色按钮后:

在点击蓝色按钮后:

在点击黄色按钮后:

看了最终效果后,给大家介绍一下皮肤文件的构成情况:
yuan.html
images3/
     left-bottom.gif
     left-top.gif
     right.gif
     right-bottom.gif
     right-top.gif
     images3.css
images-light/
     left-bottom.gif
     left-top.gif
     right.gif
     right-bottom.gif
     right-top.gif
     images3.css
images-dark/
     left-bottom.gif
     left-top.gif
     right.gif
     right-bottom.gif
     right-top.gif
     images3.css
images-notebook/
     left-bottom.gif
     left-top.gif
     right.gif
     right-bottom.gif
     right-top.gif
     images3.css
可以发现除了目录不同,文件名都是一样的。当然不同目录下的文件名虽然一样,但images3.css都一样,而图片都不一样,是不同样式的图片啦。现在让大家看一下images3.css的内容:
  1. body{
  2.     background:#ffff99;
  3.     font:12px/1.5 Arial;
  4. }

  5. .rounded h2{
  6.     margin:0;
  7.     padding:20px 20px 10px 20px;
  8. }

  9. .rounded .main{
  10.     padding:10px 20px 10px 20px;
  11.     margin:-2em 0 0 0;
  12. }

  13. .rounded .footer{
  14. }

  15. .rounded .footer p{
  16.     padding:10px 20px 20px 20px;
  17.     margin:-2em 0 0 0;
  18. }

  19. .rounded{
  20.     background:url(./left-top.gif) top left no-repeat;
  21. }

  22. .rounded h2{
  23.     background:url(./right-top.gif) top right no-repeat;
  24. }

  25. .rounded .main{
  26.     background:url(./right.gif) top right repeat-y;
  27. }

  28. .rounded .footer{
  29.     background:url(./left-bottom.gif) bottom left no-repeat;
  30. }

  31. .rounded .footer p{
  32.     background:url(./right-bottom.gif) bottom right no-repeat;
  33. }

  34. #header,#in,#pagefooter{
  35.     margin:0 auto;
  36. }

  37. #header.rounded, #in{
  38.     width:820px;
  39. }

  40. #container.rounded{
  41.     width:600px;
  42.     float:left;
  43. }

  44. #side.rounded{
  45.     width:200px;
  46.     float:right;
  47. }

  48. #pagefooter.rounded{
  49.     clear:both;
  50.     width:820px;
  51. }

  52. #btn{
  53.     margin:0 0 10px 20px;
  54.     display:inline;
  55. }

之所以会换肤,主要是html代码中的四个按钮,执行了javascript代码而已,请大家参看源代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  2. <html xmlns="">
  3. <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.     <link href="images3/images3.css" rel="stylesheet" type="text/css" id="changecss" />
  6.     
  7.     <script language="javascript">
  8.         function getCss(flag){
  9.             document.getElementById('changecss').href = flag + '/images3.css';
  10.         }
  11.         
  12.         function change(num){
  13.             var flag = '';
  14.             switch(num){
  15.                 case 1:flag = "images3";break;
  16.                 case 2:flag = "images-light";break;
  17.                 case 3:flag = "images-dark";break;
  18.                 case 4:flag = "images-notebook";break;
  19.                 default:alert("错误的皮肤号,正在返回");return false;
  20.             }

  21.             getCss(flag);
  22.         }
  23.     </script>
  24. </head>
  25. <body>
  26.     <div id="header" class="rounded">
  27.         <h2>Header</h2>
  28.         <div class="main">
  29.             <p>
  30.                 这是一行文本,这里作为样例,显示在圆角框。<br />
  31.                 这是一行文本,这里作为样例,显示在圆角框。
  32.             </p>
  33.             <p>
  34.                 这是一行文本,这里作为样例,显示在圆角框。<br />
  35.                 这是一行文本,这里作为样例,显示在圆角框。
  36.             </p>
  37.         </div>
  38.         <div class="footer">
  39.             <p>
  40.                 这是版权信息文字。
  41.             </p>
  42.         </div>
  43.     </div>
  44.     <div id="in">
  45.         <div id="container" class="rounded">
  46.             <h2>Container</h2>
  47.             <div class="main">
  48.                 <p>
  49.                     这是一行文本,这里作为样例,显示在圆角框。<br />
  50.                     这是一行文本,这里作为样例,显示在圆角框。
  51.                 </p>
  52.                 <p>
  53.                     这是一行文本,这里作为样例,显示在圆角框。<br />
  54.                     这是一行文本,这里作为样例,显示在圆角框。
  55.                 </p>
  56.                 <p>
  57.                     这是一行文本,这里作为样例,显示在圆角框。<br />
  58.                     这是一行文本,这里作为样例,显示在圆角框。
  59.                 </p>
  60.                 点这里更换网页皮肤:
  61.                 <form id="btn">
  62.                     <input type="button" style="background:red;" width="20" onclick="change(1);" />
  63.                     <input type="button" style="background:green;" width="20" onclick="change(2);" />
  64.                     <input type="button" style="background:blue;" width="20" onclick="change(3);" />
  65.                     <input type="button" style="background:yellow;" width="20" onclick="change(4);" />
  66.                 </form>
  67.             </div>
  68.             <div class="footer">
  69.                 <p>
  70.                     这是版权信息文字。
  71.                 </p>
  72.             </div>
  73.         </div>
  74.         <div id="side" class="rounded">
  75.             <h2>Side</h2>
  76.             <div class="main">
  77.                 <p>
  78.                     这是一行文本,这里作为样例,显示在圆角框。<br />
  79.                     这是一行文本,这里作为样例,显示在圆角框。
  80.                 </p>
  81.                 <p>
  82.                     这是一行文本,这里作为样例,显示在圆角框。<br />
  83.                     这是一行文本,这里作为样例,显示在圆角框。
  84.                 </p>
  85.             </div>
  86.             <div class="footer">
  87.                 <p>
  88.                     这是版权信息文字。
  89.                 </p>
  90.             </div>
  91.         </div>
  92.     </div>
  93.     <div id="pagefooter" class="rounded">
  94.         <h2>Pagefooter</h2>
  95.         <div class="main">
  96.             <p>
  97.                 这是一行文本,这里作为样例,显示在圆角框。<br />
  98.                 这是一行文本,这里作为样例,显示在圆角框。
  99.             </p>
  100.             <p>
  101.                 这是一行文本,这里作为样例,显示在圆角框。<br />
  102.                 这是一行文本,这里作为样例,显示在圆角框。
  103.             </p>
  104.         </div>
  105.         <div class="footer">
  106.             <p>
  107.                 这是版权信息文字。
  108.             </p>
  109.         </div>
  110.     </div>
  111. </body>
  112. </html>
    刚开始还一直有错,整的我很郁闷,后来发现是把getElementById写成了getElementsById,看看一个是ment一个是ments就错误。小心使得万年传啊。
阅读(5966) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

十年梦生2011-06-24 23:24:01

喜欢这个。