zoukankan      html  css  js  c++  java
  • javascript图片库威力增强版

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link rel="stylesheet" href="layout.css" media="screen"/>
    </head>

    <body onload="countBodyChildren()">
    <h1>Snapshots</h1>
    <ul>
    <li><a href="Blue hills.jpg" onclick="showPic(this);return false;" title="the mountain of blue">山峦</a></li>
    <li><a href="Sunset.jpg" onclick="showPic(this);return false;" title="red enjoy it">日出</a></li>
    <li><a href="Water lilies.jpg" onclick="showPic(this);return false;" title="a summer flower">荷花</a></li>
    <li><a href="Winter.jpg" onclick="showPic(this);return false;" title="a white world">雪林</a></li>
    </ul>
    <img id="placeholder" src="gallery.JPG" alt="my image gallery"/>
    <p id="description">Choose an image</p>
    <script type="text/javascript" src="showPic.js"></script>
    </body>
    </html>

    showPic.js

    function showPic(whichpic){
        var source=whichpic.getAttribute("href");
        var placeholder=document.getElementById("placeholder");
        placeholder.setAttribute("src",source);
        var text=whichpic.getAttribute("title");
        var description=document.getElementById("description");
        description.firstChild.nodeValue=text;
    }

    layout.css

    @charset "utf-8";
    /* CSS Document */

    body{
        font-family:Arial, Helvetica, sans-serif;
        color:#333;
        font-family:"新宋体";
        background-color:#ccc;
    }
    h1{
        color:#333;
        background-color:transparent;
    }
    a{
        color:#c60;
        background-color:transparent;
        font-weight:bold;
        text-decoration:none;
    }
    ul{
        padding:0;
    }
    li{
        float:left;
        padding:1em;
        list-style:none;
    }
    img{
        display:block;
        clear:both;
    }

  • 相关阅读:
    ES6 Syntax and Feature Overview
    Javescript——数据类型
    Javescript——变量声明的区别
    React之概述(待续)
    React之简介
    Vue.js学习之简介(待续)
    Build Telemetry for Distributed Services之OpenCensus:Tracing2(待续)
    docker之redis使用
    Build Telemetry for Distributed Services之OpenCensus:C#
    Build Telemetry for Distributed Services之Open Telemetry简介
  • 原文地址:https://www.cnblogs.com/daochong/p/4843123.html
Copyright © 2011-2022 走看看