博主信息
博文 28
粉丝 1
评论 0
访问量 21575
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
2019.5.8作业
关超的博客
原创
670人浏览过

QQ图片20190509153145.png

<html>
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <style type="text/css">
        .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;
        }
        .box ul {
            margin:0;
            padding:0;
            /*将ul转为BFC独立块,使之不受内部浮动元素的影响*/
            overflow: hidden;
        }
        .box ul li {
            list-style-type: none;
            float:left;
            background-color: skyblue;
            margin-left: 55px;
        }

        .box ul li a {
            display: block;
            width: 100px;
            height: 40px;
            line-height: 40px;
            color: white;
            text-decoration: none;
        }
        .box ul li:hover {
            font-size:1.2em;
            background-color: coral;
        }

        .active {
            font-size:1.2em;
            background-color: coral;
        }

        .box .pic {
            width: 450px;
            height:450px;
            border: 1px solid lightgray;
            margin: 50px auto 0;
        }

        .box .pic img {
            width: 100%;
            height: 100%;
        }

    </style>
</head>
<body>
<div class="box">
    <h2>景色欣赏</h2>
    <ul>
        <li>
            <a href="yw.jpg" title="夜晚的景色.....">夜色</a>
        </li>
        <li>
            <a href="yw2.jpg" title="日出的景色......">日出</a>
        </li>
        <li>
            <a href="yw3.jpg" title="小岛周边景色......">小岛</a>
        </li>        
    </ul>
    <div class="pic">
        <img src="images/zwt.png" alt="" id="img">
    </div>
    <p id='info'></p>
</div>

<script>
    var pic = document.getElementsByTagName('a');
    var img = document.getElementById('img');
    var p = document.getElementById('info');
       
    for (var i = 0; i < pic.length; i++) {
        pic[i].onclick = function () {
            for (var i = 0; i < pic.length; i++) {
                pic[i].classList.remove('active');
            }
            this.classList.add('active');

            var picUrl = this.href;
            var picInfo = this.title;
            var picName = this.innerHTML;

            img.src = picUrl;
            p.innerHTML = '<span style="color:coral">'+picName+':'+picInfo+'</span>';
            return  false;
        };
    }
</script>
</body>
</html>



本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学