zoukankan      html  css  js  c++  java
  • 简单的点击切换图

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>练习</title>
    <style type="text/css">

    *{
    margin: 0;
    padding: 0;
    margin: 0 auto;
    }

    .cas{
    margin-top: 100px;
    400px;
    height: 430px;
    background-color: skyblue;

    }

    #cssa{
    160px;
    height: 360px;

    /*margin-top: -100px;*/
    background:url(images/2.jpg) top center;

    }
    .shubai{
    cursor: pointer;
    /*margin-top: 100px;*/
    }
    /*.shubai ul{
    float: left;
    list-style: none;
    }*/
    .shubai ul .casa1{
    float: left;
    60px;
    height: 20px;
    }
    .shubai ul .casa2{
    float: left;
    60px;
    height: 20px;
    }
    .shubai ul .casa3{
    float: left;
    60px;
    height: 20px;
    }
    .shubai ul .casa4{
    float: left;
    60px;
    height: 20px;
    }
    .shubai ul .casa5{
    float: left;
    60px;
    height: 20px;
    }

    .shubai li{
    40px;
    height: 20px;
    margin-top: 390px;

    list-style: none;

    /*line-height: 18px;*/
    background-color: #3E3E3E;
    float: left;
    text-align: center;
    color: #FFFFFF;
    /*border-radius: 50%;*/
    /*margin: 0 40px 0 60px;*/
    /*cursor: pointer;*/
    margin-left: 16px;
    }

    </style>
    </head>
    <body>

    <div class = "cas">

    <div class = "shubai">
    <ul class = "kaishi">
    <li class = "casa1" id = "pxc1">picture1</li>
    <li class = "casa2" id = "pxc2">picture2</li>
    <li class = "casa3" id = "pxc3">picture3</li>
    <li class = "casa4" id = "pxc4">picture4</li>
    <li class = "casa5" id = "pxc5">picture5</li>
    </ul>

    </div>
    <div id ="cssa"></div>
    </div>

    <script type="text/javascript">

    var pxc = document.getElementById("cssa");

    var p1 = document.getElementById("pxc1");
    var p2 = document.getElementById("pxc2");
    var p3 = document.getElementById("pxc3");
    var p4 = document.getElementById("pxc4");
    var p5 = document.getElementById("pxc5");

    pxc1.onclick = function(){
    pxc.style.backgroundImage = "url(images/1.jpg)";

    }
    pxc2.onclick = function(){
    pxc.style.backgroundImage = "url(images/2.jpg)";
    }
    pxc3.onclick = function(){
    pxc.style.backgroundImage = "url(images/3.jpg)";
    }
    pxc4.onclick = function(){
    pxc.style.backgroundImage = "url(images/4.jpg)";
    }
    pxc5.onclick = function(){
    pxc.style.backgroundImage = "url(images/5.gif)";
    }

    </script>

    </body>
    </html>

  • 相关阅读:
    LeetCode Missing Number (简单题)
    LeetCode Valid Anagram (简单题)
    LeetCode Single Number III (xor)
    LeetCode Best Time to Buy and Sell Stock II (简单题)
    LeetCode Move Zeroes (简单题)
    LeetCode Add Digits (规律题)
    DependencyProperty深入浅出
    SQL Server存储机制二
    WPF自定义RoutedEvent事件示例代码
    ViewModel命令ICommand对象定义
  • 原文地址:https://www.cnblogs.com/xiaohaishuangyu/p/6009944.html
Copyright © 2011-2022 走看看