Blogger Information
Blog 16
fans 0
comment 0
visits 12601
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
5.8相册学习
如花似玉的小牛牛的博客
Original
820 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>相册</title>
    <style>
        div[id="box"] {

            width: 500px;
            height: 700px;
            background-color: #efefef;
            border: 1px solid lightgray;
            margin: 20px auto;
            text-align: center;
            color: #636363;
            box-shadow: 2px 2px 2px #999;
        }
        div[id="box"] ul>li{

            list-style-type: none;
            float: left;
            margin-left: 20px;
            background-color: #39c3ff;
            font-size: 18px;


            display: block;
            margin-bottom: 10px;
        }
        div[id="box"] ul>li>a {
            color: white;
            display: block;

            width: 100px;
            height: 40px;
            line-height: 40px;

            text-decoration: none;
        }
        }
    </style>
</head>
<body>
<div id="box">
    <h2>相册</h2>
    <ul>
        <li><a href="images/fbb.jpg" title="《还珠格格》,《武媚娘传奇》,《我不是潘金莲》...">范冰冰</a></li>
        <li><a href="images/zly.jpg" title="《楚乔传》,《花千骨》,《陆贞传奇》..">赵丽颖</a></li>
        <li><a href="images/sl.jpg" title="《那年花开月正圆》,《甑环传》,《玉观音》...">孙俪</a></li>
        <li><a href="images/gyy.jpg" title="《倚天屠龙记》,《咱们经婚吧》,《爱无悔》...">高圆圆</a></li>
    </ul>
    <div id="pic"><img src="images/zwt.png" style="width: 400px; height: 400px;" id="img"> </div>
    <p id="info">....</p>
</div>
<script>
    var ali = document.getElementsByTagName('a');
  //  var pic = document.getElementById( 'img' );     //获取id为img的
    var p = document.getElementById( 'info' );      //获取id为info的

    for ( i=0; i<ali.length; i++) {
        ali[i].onclick = function () {

            var imgurl = this.href;
            var imgtitle = this.title;
            var neirong = this.innerHTML;
            img.src = imgurl;
            p.innerHTML = '<span style="color:coral">'+neirong+':'+imgtitle+'</span>';
            return  false;
        };
    }

</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post