首页 > 其他分享 >vue与jquery两种方式实现手风琴动效

vue与jquery两种方式实现手风琴动效

时间:2023-03-16 13:44:24浏览次数:47  
标签:jquery vue 100% item 动效 repeat background images png

1. jquery方式实现点击事件动效

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>jquery主页手风琴动效</title>
    <script src="https://s1.pstatp.com/cdn/expire-1-M/jquery/1.10.2/jquery.min.js"></script>
    <style type="text/css">
      * {
        margin: 0;
        padding: 0;
      }
      body {
        background-color: #171717;
      }
      .box {
        width: 1168px;
        height: 519px;
        background: red;
        margin: 50px auto;
      }

      .item {
        width: 119px;
        height: 519px;
        float: left;
        transition: width 0.2s;
      }

      .item:nth-child(1) {
        background: url("images/feature-1.png") no-repeat 100% 100%;
        /*background-size: 100% 100%; 背景图尺寸 */
      }

      .item:nth-child(2) {
        background: url("images/feature-2.png") no-repeat 100% 100%;
      }

      .item:nth-child(3) {
        background: url("images/feature-3.png") no-repeat 100% 100%;
      }

      .item:nth-child(4) {
        background: url("images/feature-4.png") no-repeat 100% 100%;
      }

      .item:nth-child(5) {
        background: url("images/feature-5.png") no-repeat 100% 100%;
      }

      .big {
        width: 692px;
      }

      .big img {
        display: none;
        height: 519px;
      }
    </style>
    <script type="text/javascript">
      $(function () {
        $(".item").click(function () {
          $(this).addClass("big").siblings().removeClass("big");
        });
      });
    </script>
  </head>
  <body>
    <div class="box">
      <div class="item big"><img src="images/01.png" alt="" /></div>
      <div class="item"><img src="images/02.png" alt="" /></div>
      <div class="item"><img src="images/03.png" alt="" /></div>
      <div class="item"><img src="images/04.png" alt="" /></div>
      <div class="item"><img src="images/05.png" alt="" /></div>
    </div>
  </body>
</html>

2. vue方式实现点击事件动效

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>vue主页手风琴动效</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style type="text/css">
      * {
        margin: 0;
        padding: 0;
      }
      body {
        background-color: #171717;
      }
      .box {
        width: 1168px;
        height: 519px;
        background: red;
        margin: 50px auto;
      }

      .item {
        width: 119px;
        height: 519px;
        float: left;
        transition: width 0.2s;
      }

      .item:nth-child(1) {
        background: url("images/feature-1.png") no-repeat 100% 100%;
        /*background-size: 100% 100%; 背景图尺寸 */
      }

      .item:nth-child(2) {
        background: url("images/feature-2.png") no-repeat 100% 100%;
      }

      .item:nth-child(3) {
        background: url("images/feature-3.png") no-repeat 100% 100%;
      }

      .item:nth-child(4) {
        background: url("images/feature-4.png") no-repeat 100% 100%;
      }

      .item:nth-child(5) {
        background: url("images/feature-5.png") no-repeat 100% 100%;
      }

      .big {
        width: 692px;
      }

      .big img {
        display: none;
        height: 519px;
      }
    </style>
  </head>
  <body>
    <div id="container" class="box">
      <div
        v-for="(item, index) in imgList"
        :class="{
          item:true,
          big: selectIndex === index
        }"
        @click="selectIndex = index"
      >
        <img :src="item" alt="" />
      </div>
    </div>

    <script type="text/javascript">
      var vm = new Vue({
        el: "#container",
        data: {
          selectIndex: 0,
          imgList: [
            "images/01.png",
            "images/02.png",
            "images/03.png",
            "images/04.png",
            "images/05.png",
          ],
        },
      });
    </script>
  </body>
</html>

注:里面的图片自己可以找替换的,或者参考链接
作者:白马不是马

标签:jquery,vue,100%,item,动效,repeat,background,images,png
From: https://www.cnblogs.com/DTCLOUD/p/17222248.html

相关文章

  • maui BlazorWebView+本地html (vue、uniapp等都可以) 接入微信sdk 开发 Android ap
       之前没接触过Androidmaui开发,这几天刚摸索,有些不合理的地方欢迎指出。首先添加微信sdk的绑定库  nuget包:Chi.MauiBinding.Android.WeChat 项目地址:http......
  • Vue.js 绑定class样式
    视频<!DOCTYPEhtml><html> <head> <metacharset="UTF-8"/> <title>绑定样式</title> <style> .basic{ width:400px; height:100px; border:......
  • Vue.js 监视属性(p20~p25)
    视频21视频22视频23视频24视频25天气案例<!DOCTYPEhtml><html> <head> <metacharset="UTF-8"/> <title>天气案例</title> <!--引入Vue--> <scriptty......
  • K8S配置vue
    1、编写Dockerfile1)、Dockerfile文件FROMnginx:1.22.1COPYdist/etc/nginx/vueTemplateEXPOSE30098CMD["nginx","-g","daemonoff;"]2)、制作镜像dockerbu......
  • Vue利用slice()方法实现分页操作
    Vue利用slice()方法实现分页操作https://blog.csdn.net/pleaseprintf/article/details/129187584系列文章目录提示:这里可以添加系列文章的所有文章的目录,目录需要......
  • 前后端分离项目(vue+springboot)集成pageoffice实现在线编辑office文件
    前后端分离项目下使用PageOffice原理图集成步骤前端vue项目在您Vue项目的根目录下index.html中引用后端项目根目录下pageoffice.js文件。例如:<scripttype="te......
  • 宝塔部署history模式的vue3项目
    前置条件:服务器、域名、备案、项目首先进入宝塔点击左侧的网站,然后点击添加站点 填入域名,点击提交,宝塔会自动帮忙创建一个根目录到该根目录,把打包后的vue项目放......
  • VUE的setup、ref、reactive和代理数据的使用
    一.VUE的setup、ref、reactive和代理数据的使用1.1setup和ref先来实现一个简单的点击按钮,数字增加的案例:需求:页面打开后可以直接看到一个数据,点击按钮后,该数据可以发生......
  • Vue 代理服务器___Vue 跨域通过Axios 的ajax方式的get请求获取数据
    Vue代理服务器___Vue跨域通过Axios的ajax方式的get请求获取数据1、说明1.1:配置2台本地服务器说明:node_modules为vue脚手架        package.json为静态数据......
  • Vue封装的过度与动画
    Vue封装的过度与动画1:知识点:##Vue封装的过度与动画1.作用:在插入、更新或移除DOM元素时,在合适的时候给元素添加样式类名。2.图示:<imgsrc="https://img04.sogoucdn......