前端炫酷展开效果

效果图

因为图片大小的问题换成了手机尺寸录制

.vue

bash 复制代码
<template>
  <div class="expand">
    <div class="expand-main" @wheel="handleWheel"
      :style="`--location:${location}%;--load-location:${location * -1}%;`">
      <!-- <video class="expand-media expand-left" autoplay loop muted playsinline src="/src/assets/瑶-大耳狗之梦-动态海报.mp4" />
      <video class="expand-media expand-right" autoplay loop muted playsinline src="/src/assets/瑶-大耳狗之梦-动态海报.mp4" /> -->
      <img class="expand-media expand-left" :src="media" />
      <img class="expand-media expand-right" :src="media" />
      <div class="expand-container">
        <div class="expand-content">
          <h1 class="expand-content-title">独行道</h1>
          <div v-html="text"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const media = 'https://get.hnzmsz.com/gw/swiper-4.jpg'
const heightMax = 50
const location = ref(0)
const text = `<p>我清楚地知道人与人的路是不可复制的,我走在我自己的人生路上,哪怕路途的风雨再大,大到我举步维艰,哪怕荆棘丛生,刺得我伤痕遍布,我也仍旧痴痴笑笑体会此中滋味。</p>
<p>人的一生之精彩,在于自己追逐梦想的过程。不必苛求旁人的不失望或者喜欢。走自己的路,让旁人失望和不喜欢去吧。</p>
<p>人啊,走在自己的人生路上,就不要怕肮脏!踩着白骨和血肉,一步步走向辉煌!人啊,走在自己的人生路上,就不要怕悲伤!岂不闻 "天无绝人之路"!只要我想走,路就在脚下!</p>`
const handleWheel = (event) => {
  if (event.deltaY > 0) location.value = heightMax <= location.value ? heightMax : location.value + 10
  else location.value = 0 < location.value ? location.value - 10 : 0
};
</script>

<style scoped lang='scss'>
.expand{
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;

  &-main{
    width: 100%;
    height: calc(100% + 1px);
    position: absolute;
    left:0;
    top: 0;
    overflow: hidden;
  }

  &-media{
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 1;
    object-fit: cover;
    transition: transform 0.2s ease; 
    will-change: transform;
  }

  &-left{
    clip-path: polygon(0 0, 0 100%, 100% 100%);
    top: -.5px;
    left: 0;
    transform: translate3d(var(--load-location), var(--location), 0);
  }

  &-right{
    clip-path: polygon(0 0, 100% 100%, 100% 0);
    top:0;
    right: 0;
    transform: translate3d(var(--location), var(--load-location), 0);
  }

  &-container{
    position: absolute;
    top: calc(100% - (var(--location) * 2));
    width: 100%;
    transition: top 0.2s ease;
  }

  &-content{
    max-width: 90%;
    width: max-content;
    margin: 0 auto;
    line-height: 30px;

    &-title{
      text-align: center;
    }
  }
}
</style>

遇到问题可以看我主页加我,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
hiahiahia12317 分钟前
Streaming Model Output
开发语言·前端
paopaokaka_luck18 分钟前
基于springboot+vue的益暖微光公益服务平台(DeepSeek公益助手、善款信息追溯、志愿服务积分闭环、ECharts运营分析、活动状态自动流转)
java·前端·javascript·spring boot·mysql·架构·echarts
栀椩28 分钟前
Electron 内嵌页面跨域问题(CORS/PNA)解决全记录
前端·javascript·electron
asaotomo33 分钟前
截图识题、AI 讲解、笔记沉淀:Chrome 扩展体验
前端·chrome·笔记
前端架构师-老李35 分钟前
HTML与CSS基础第五课—HTML的空格、换行、横线相关知识
前端·css·html
SEO_juper36 分钟前
Chrome 扩展一键查看当前页面 SEO 信息:不用切页面,点一下全出来
前端·javascript·chrome
Highcharts.js39 分钟前
CSUN 2026|Highcharts无障碍数据与AI分享
javascript·人工智能·数据分析·highcharts·图表开发
Nymph_Zhu43 分钟前
vue3+element-plus 文件上传
前端·typescript·vue3·element-plus
echome8881 小时前
CSS 布局:Flex 和 Grid 怎么选,附常见坑
前端·css·html
计算机魔术师1 小时前
科技巨头砸7400亿押注AI,为什么苹果成了唯一赢家?
前端