【vue2】vue2 实现手风琴效果,复制粘贴直接使用

简介: 【vue2】vue2 实现手风琴效果,复制粘贴直接使用

【vue2】vue2 实现手风琴效果,复制粘贴直接使用

效果

代码

<template>
  <div
    class="about-index"
    :style="{ backgroundImage: 'url(' + lisData.img + ')' }"
  >
    <div class="container">
      <div class="fine-grained">
        <h1>高山流水遇知音</h1>
        <div class="content">
          <!-- 左边 -->
          <div class="left">
            <div class="or-container">
              <div
                class="box"
                :class="eleindex == i ? 'eleactive' : ''"
                v-for="(ele, i) in piclist"
                :key="i"
                @mouseenter="enter(i, ele)"
                @mouseleave="out(i)"
                @click="ounds(ele)"
              >
                <img :src="ele.img" />
                <div class="wenb">
                  <div>{{ ele.title }}</div>
                  <div>{{ ele.name }}</div>
                </div>
              </div>
            </div>
          </div>

          <!-- 右边 -->
          <div class="right">
            <p>{{ lisData.title }}:</p>
            <div>
              {{ lisData.describe }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "index",
  data() {
    return {
      eleindex: 0,
      piclist: [
        {
          title: "看山",
          describe: "青山看不厌,流水趣何长",
          img: "https://img-qn.51miz.com/preview/photo/00/01/51/26/new-P-1512602-6C1160D0O.jpg!/quality/90/unsharp/true/compress/true/fwfh/640x420",
        },
        {
          title: "看水",
          describe: "花香莹把往日情勾起 我愿意化浮萍躺湖心",
          img: "https://img-qn.51miz.com/preview/photo/00/01/51/46/new-P-1514606-AED53C34O.jpg!/quality/90/unsharp/true/compress/true/fwfh/800x800",
        },
        {
          title: "看风景",
          describe: "千里莺啼绿映红,水村山郭酒旗风",
          img: "https://img-qn.51miz.com/2017/06/29/21/2017062921665894_P1247958_238470d3O.jpg!/quality/90/unsharp/true/compress/true/fwfh/640x420",
        },
      ],
      lisData: {
        title: "看山",
        describe: "青山看不厌,流水趣何长",
        img: "https://img-qn.51miz.com/preview/photo/00/01/51/26/new-P-1512602-6C1160D0O.jpg!/quality/90/unsharp/true/compress/true/fwfh/640x420",
      },
    };
  },
  methods: {
    enter: function (i, ele) {
      this.eleindex = i;
      this.lisData = ele;
    },
    out: function (i) {
      this.imgindex = -1;
    },
    ounds(ele) {
      console.log(ele);
    },
  },
  created() {},
};
</script>
 
<style scoped>
.about-index {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
}
.container {
  width: 1200px;
  height: auto;
  margin: 0 auto;
}
/*手风琴样式*/
.or-container {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
}

.or-container:before {
  background-color: rgba(0, 0, 0, 0.4);
}

.box {
  flex: 1;
  overflow: hidden;
  transition: 0.5s;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.1);
  line-height: 0;
  border-radius: 5px;
  margin: 0px 2px;
  position: relative;
}

.box > img {
  width: 100%;
  height: calc(100%);
  -o-object-fit: cover;
  object-fit: cover;
  transition: 0.5s;
  border-radius: 5px;
  margin: 0px 2px;
  position: relative;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(25, 23, 19, 0) 0%, #613321 100%);
}

.wenb {
  position: absolute;
  left: 0px;
  bottom: 0px;
  color: #fff;
  padding: 5px 15px;
  border-radius: 10px;
}

.wenb div:nth-child(1) {
  width: 80px;
  height: 25px;
  font-size: 18px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #ffffff;
  line-height: 25px;
}

.wenb div:nth-child(2) {
  width: 50px;
  height: 25px;
  font-size: 16px;
  font-family: PingFangSC-Semibold, PingFang SC;
  /* font-weight: 600; */
  color: #ffffff;
  line-height: 25px;
}

.eleactive {
  flex: 1 1 22%;
}

.eleactive > img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}

/*end*/

.about-index .content {
  padding: 24px 0px 10px 0px;
  font-size: 16px;
  font-family: SourceHanSerifSC-Regular, SourceHanSerifSC;
  font-weight: 400;
  color: #333333;
  line-height: 30px;
  display: flex;
}

.about-index .content .leftd {
  width: 500px;
  height: 298px;
  /* background-color: pink; */
  overflow: hidden;
}

.about-index .fine-grained .content {
  /* background: #f2e6d1; */
  display: flex;
  justify-content: space-between;
}

.fine-grained .content .left {
  width: 44%;
  /* height: 189px; */
  /* background-color: pink; */
}

.fine-grained .content .right {
  width: 760px;
  height: 450px;
  background: #f2e5d1;
  border-radius: 10px;
  padding: 20px;
}

.fine-grained .content .right p {
  margin: 0px 0px 10px 0px;
  width: 80px;
  height: 22px;
  font-size: 16px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #333333;
  text-align: left;
  line-height: 22px;
}

.fine-grained .content .right div {
  width: 700px;
  /* height: 256px; */
  font-size: 16px;
  font-family: PingFangSC-Semibold, PingFang SC;
  /* font-weight: 600; */
  color: #333333;
  line-height: 32px;
  text-indent: 28px;
  text-align: left;
}

/* .about-index .introduction .content {
  background: #f2e6d1;
} */
</style>
目录
打赏
0
1
1
0
14
分享
相关文章
|
7月前
|
使用Vue实现一个当鼠标悬浮时出现,鼠标离开时消失的双层菜单
这篇文章介绍了如何在Vue中实现一个鼠标悬浮时出现、鼠标离开时消失的双层菜单,并提供了详细的代码示例和运行效果展示。
598 0
|
7月前
|
基于Vue2或Vue3实现任意上下左右拖拽悬浮的元素,且配置为自定义的全局指令
这篇文章介绍了如何在Vue 2或Vue 3项目中实现一个自定义的全局指令`v-dragSwitch`,用于创建可以任意方向拖拽并悬浮的元素,同时包含边界处理的逻辑。
1940 2
基于Vue2或Vue3实现任意上下左右拖拽悬浮的元素,且配置为自定义的全局指令
vue实现侧边折叠菜单栏手风琴效果
该文章介绍了如何使用Vue.js实现具有手风琴效果的侧边折叠菜单栏,包括HTML结构设计、CSS样式设置以及JavaScript交互逻辑的编写。
Vue2走马灯扩展版(Carousel)
这篇文章介绍了如何在Vue 3框架中创建一个可自定义的走马灯(Carousel)组件,支持自动播放、导航、分页和响应用户交互等功能。
328 0
Vue2走马灯扩展版(Carousel)
【vue】 el-table解决分页不能筛选全部数据的问题
【vue】 el-table解决分页不能筛选全部数据的问题
657 4
|
10月前
|
【vue】vue2 粒子特效
【vue】vue2 粒子特效
181 2
|
10月前
|
【vue】vue2 获取本地IP地址
【vue】vue2 获取本地IP地址
312 1
nvm安装与使用详解(Window11)
nvm安装与使用详解(Window11)
438 0
如何在ClickHouse中处理时序数据
ClickHouse具有强大的工具,可以高效地存储和处理时序数据,并可用于简单的解决方案和数据发掘,以及支持PB级的实时分析应用。
【vue2】vue2 适配pc端,解决浏览器缩放问题,解决电脑显示设置缩放、分辨率问题
【vue2】vue2 适配pc端,解决浏览器缩放问题,解决电脑显示设置缩放、分辨率问题
907 1

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等