JS实现花瓣网轮播图效果(未测试)


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"">  
        <head>  
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
            <title>index</title>  
            <style>  
                body{  
                    background:#57beb9;  
                }  
                #main{  
                    width:920px;  
                    /*border: 1px solid red;*/  
                    height:430px;  
                    overflow:hidden;  
                    position:relative;  
                    margin:30px auto;  
                }  
                #main .box{  
                    width:820px;  
                    height:430px;  
                    box-shadow:0px 0px 5px #ddd;  
                    margin:0px auto;  
                    overflow:hidden;  
                    /*border: 2px solid blue;*/  
                    position:relative;  
                }  
                #main .box img{  
                    width:820px;  
                    height:430px;  
                    position:absolute;  
                    left:0px;  
                    top:0px;  
                    opacity:0;  
                    filter:alpha(opacity=0);  
                }  
                #main .btnLeft{  
                    width:35px;  
                    height:57px;  
                    position:absolute;  
                    left:0px;  
                    top:185px;  
                    /*border: 1px solid yellow;*/  
                    background:url(./images/left_ar.png) no-repeat 0px 0px;  
                }  
                #main .btnRight{  
                    width:35px;  
                    height:57px;  
                    position:absolute;  
                    right:0px;  
                    top:185px;  
                /*  border: 1px solid yellow;*/  
                    background:url(./images/right_ar.png) no-repeat 0px 0px;  
                }  
                #main  .page{  
                    width:132px;  
                    height:22px;  
                    position:absolute;  
                    bottom:15px;  
                    right:50px;  
                }  
                #main  .page a{  
                    display:inline-block;  
                    width:22px;  
                    height:22px;  
                    background:url(./images/num_grey.png) no-repeat 0px 0px;  
                    margin:0px 11px;  
                    float:left;  
                    color:#FFF;  
                    text-decoration:none;  
                    text-align:center;  
                }  
                #main  .page a.active{  
                    background:url(./images/num_red.png) no-repeat 0px 0px;  
                }  
            </style>  
            <script src="jquery.js"></script>  
            <script>  
               $(function(){  
                  var apage=$('#main .page a');  
                  var aimg=$('#main .box img');  
                  var index=0;  
                  var asize=aimg.size();  
                   $('#btnLeft').click(function(){  
                       index--;  
                       if(index<0){  
                        index=asize-1;  
                        document.title=index;  
                      }  
                      change();  
                    })  
                   $('#btnRight').click(function(){  
                       index++;  
                       if(index>asize-1){  
                        index=0;  
                        document.title=index;  
                      }  
                      change();  
                    })  
                 apage.click(function(){  
                      index=$(this).index();  
                      change();  
                  });  
                  function change(){  
                      apage.removeClass('active');  
                      apage.eq(index).addClass('active');  
                      aimg.eq(index).siblings().stop().animate({  
                          opacity: 0  
                      },300)  
                      aimg.eq(index).stop().animate({  
                          opacity: 1  
                      },300)  
                  }  
                })  
            </script>  
        </head>  
        <body>  
            <div id="main">  
                <a class='btnLeft' id="btnLeft" href="javascript:void(0);"> </a>  
                <a class='btnRight' id="btnRight" href="javascript:void(0);"> </a>   
                <div class="box">  
                    <img style="opacity:1;filter:alpha(opacity=100);" src="./images/intro1.jpg"/>               
                    <img src="./images/intro2.jpg"/>  
                    <img src="./images/intro3.jpg"/>  
                </div>  
                <div class='page'>  
                    <a  class='active'  href="javascript:void(0);">1</a>  
                    <a  href="javascript:void(0);">2</a>  
                    <a href="javascript:void(0);">3</a>  
                </div>  
            </div>  
        </body>  
    </html>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用 particles.js 实现花瓣效果,你可以按照以下步骤进行操作: 1. 下载 particles.js 库:你可以从 particles.js 的 GitHub 页面上下载库文件。将其添加到你的项目中。 2. 创建一个容器:在你的 HTML 文件中,创建一个容器元素来承载粒子效果。例如: ```html <div id="particles-js"></div> ``` 3. 初始化粒子效果:在你的 JavaScript 文件中,使用以下代码初始化 particles.js: ```javascript particlesJS('particles-js', { "particles": { "number": { "value": 100, // 粒子数量 "density": { "enable": true, "value_area": 800 // 粒子分布密度 } }, "shape": { "type": "image", // 使用图片作为粒子形状 "image": { "src": "path/to/flower.png", // 花瓣图片路径 "width": 100, // 图片宽度 "height": 100 // 图片高度 } }, "size": { "value": 20, // 粒子大小 "random": true, // 随机大小 "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false } }, // 其他粒子属性设置(颜色、透明度等) // ... }, // 其他配置项(背景颜色、互动性等) // ... }); ``` 注意,以上代码中的 `"path/to/flower.png"` 应替换为你自己的花瓣图片路径。 4. 样式调整:根据需要,你可以使用 CSS 来调整容器的大小、位置以及其他样式属性,以适应你的项目需求。 通过以上步骤,你就可以使用 particles.js 实现花瓣效果了。记得根据你的具体需求调整粒子数量、分布密度、花瓣图片路径等参数。祝你成功实现花瓣效果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值