You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Vite项目页面滚动回弹时Footer无法拉伸的问题求助

React Vite项目滚动回弹时Footer无法拉伸的问题

在我的React Vite项目中,页面滚动至底部触发回弹效果时,Footer无法跟随拉伸,会脱离页面左下角和右下角,露出主题底色,不符合预期。

尝试过的方案

  • 将body背景色设置为目标颜色,但导致About、Experience、Portfolio和Contact等所有区块元素都继承了该颜色
  • 为Footer容器添加flex-grow属性,但没有效果

咨询

应该采用让Footer强制拉伸的方案(尽管目前不生效),还是设置一个背景容器为目标颜色,同时将所有区块元素设置为主题色以保证配色正常?


App.jsx(Footer的父组件)

<BrowserRouter>
  <div className='relative z-0 flex flex-col min-h-screen '>
    {!lampToggle && (
      <Navbar
        heroRef={heroRef}
        animationClass={navbarAnimate ? 'navbar-animate' : ''}
        selectedLang={selectedLang}
        setSelectedLang={setSelectedLang}
      />
    )}
    <div className='flex-grow-1 page-container '>
      <div className='relative z-0'>
        <Hero
          setLampToggleApp={() => setLampToggle(!lampToggle)}
          ref={heroRef}
        />
      </div>

      <About />
      <Experience />

      <Works onProjectClick={handleModalClick} />

      {showModal && (
        <ProjectModal
          modalProject={modalProject}
          onClose={() => setShowModal(false)}
        />
      )}
      <Feedbacks />

      <div className='relative z-0'>
        <Contact />
        <StarsCanvas />
      </div>
      <Footer />
    </div>
  </div>
</BrowserRouter>
import React from 'react';

const Footer = () => {
const currentYear = new Date().getFullYear();
const yourName = '© K';

return (
<div
  className='absolute bottom-0 left-0 right-0 w-full bg-black 
  text-white flex justify-center items-center text-sm p-2'
  style={{ zIndex: '9999' }}
   >
  <p className='garet-book'>{yourName}</p>
  <p className='garet-book ml-2'>{currentYear}</p>
  </div>
  );
 };

export default Footer;

内容的提问来源于stack exchange,提问作者kib

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 10:22:32