next.js React-player for vimeo显示播放器一开始很小

hfwmuf9z  于 2023-04-05  发布在  React
关注(0)|答案(1)|浏览(150)

我已经在我的Next.js应用程序中安装了Reactplayer包,我试图加载Vimeo视频。但在初始渲染过程中,播放器似乎很小,然后它就像屏幕截图中的那样扩展了。
初始

渲染后

下面是我使用React播放器进行响应的片段
Package

<div className="relative w-[100%] mobile:w-[70%] pt-[56.25%] mobile:pt-[40%] bg-gold-label-pastel">
  <div>
    <ReactPlayer
      className="react-player"
      width="100%"
      height="100%"
      url="https://player.vimeo.com/video/786201103"
      controls={true}/>
   </div>
 </div>

CSS

.react-player {
  position: absolute;
  top: 0;
  left: 0;
}
pokxtpni

pokxtpni1#

试着像这样移除围绕在实际播放器周围的div ...

<div className="relative w-[100%] mobile:w-[70%] pt-[56.25%] mobile:pt-[40%] bg-gold-label-pastel">
    <ReactPlayer
      className="react-player"
      width="100%"
      height="100%"
      url="https://player.vimeo.com/video/786201103"
      controls={true}
     />
 </div>

相关问题