C1任务04 计算机程序逻辑

任务一:生成图片广告

第一步:能够用HTML+CSS+javaScript在页面正中生成一幅广告图片

(1)、在网上搜索图片后保存,多下载几张,方便后面用

(2)、代码展示图如下

(3)、效果图如下

第二步:用在页面上放置多张广告图片,同时动态计算不同告位之间的布局,实现水平等间距布局

(1)、代码图如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
    img{
        width: 200px;
        height: 200px;
        padding: 30px;
        float: left;
        }


    </style>

</head>
<body>
    <div class="picture">
      <img src="C:\Users\Administrator\Desktop/1.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/8.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/2.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/3.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/4.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/5.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/6.jpg" height="200" width="200"/>
        <img src="C:\Users\Administrator\Desktop/7.jpg" height="200" width="200"/>
    </div>
</body>
</html>

(2)、效果图如下:

第三步:用JavaScript代码实现多张广告图片轮播效果:在页面正中每隔3秒切换不同的广告图片,多张图片轮番显示。

(1)、代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        #show{
        width: 400px;
        height: 300px;
       margin: 0 auto;
            overflow: hidden;
        }
        #concent{
            width: 1600px;
        height: 300px;

        }
        #concent>div{
            float:left;
        }
    </style>
    </head>
<body>
   <div id="show">
       <div id="concent">
           <div>
               <img src="photos/1.jpg" alt="">
               </div>
           <div>
               <img src="photos/2.jpg" alt="">
               </div>
           <div>
               <img src="photos/3.jpg" alt="">
               </div>
           <div>
               <img src="photos/4.jpg" alt="">
               </div>
           <div>
               <img src="photos/5.jpg" alt="">
               </div>
           <div>
               <img src="photos/6.jpg" alt="">
               </div>
           <div>
               <img src="photos/7.jpg" alt="">
               </div>
           <div>
               <img src="photos/8.jpg" alt="">
               </div>
   </div>
   </div>
         <script>
             var speed=10;
             function movepicture() {
                 var concent = document.getElementById("concent");
                 var left = concent.style.marginLeft;
                 concent = left == "" ? 0 : parseInt(left - speed) + "px";
                 if (left - speed == -1600) {
                     concent.style.marginLeft = "0px"
                 }
                 var interid = setInterval(function () {
                     movepicture();
                 }, 100)
             }
            </script>
    </div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值