简体   繁体   English

Lotties 在我的 NextJS 项目中有黑色背景。 我怎样才能使它们透明?

[英]Lotties have a black background in my NextJS project. How can I make them transparent?

All my LottieFiles (JSON) have a black background when I import them onto my NextJS project.当我将它们导入我的 NextJS 项目时,我所有的 LottieFiles (JSON) 都有黑色背景。 I tried setting background='transparent' on both the Player or the parent div, to no avail.我尝试在 Player 或父 div 上设置background='transparent' ,但无济于事。

I made sure to export my Lotties with a transparent background directly from the Lottie editor.我确保直接从 Lottie 编辑器导出具有透明背景的 Lotties。

<HeroAnimation>
     <Player
      autoplay
      loop
      src={HeroTextAnimation}
      background='transparent'>
         <Controls visible={false} />
     </Player>
</HeroAnimation>

Note: HeroAnimation tag is a styled component div -- see below:注意:HeroAnimation 标签是一个带样式的组件 div——见下文:

const HeroAnimation = styled.div`
    height: 554px;
`;

package.json dependencies: package.json 依赖项:

  "dependencies": {
    "@chakra-ui/icons": "^2.0.15",
    "@lottiefiles/react-lottie-player": "^3.5.0",
    "@next/font": "13.1.1",
    "eslint": "8.31.0",
    "eslint-config-next": "13.1.1",
    "next": "13.1.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "styled-components": "^5.3.6"
  }

Tried other libraries (ie lottie-react) to see if it was a library-dependent issue.尝试了其他库(即 lottie-react)以查看它是否是库相关的问题。 Currently using "@lottiefiles/react-lottie-player"目前正在使用“@lottiefiles/react-lottie-player”

If your library renders the Lottie to SVG in the DOM you can use a CSS selector to change the color of the SVG path/shape.如果您的库在 DOM 中将 Lottie 渲染为 SVG,您可以使用 CSS 选择器来更改 SVG 路径/形状的颜色。

Global css was adding a black background to every element -- I removed it and it worked. Global css 为每个元素添加了黑色背景——我删除了它并且它起作用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有一个视频背景引导页面。 如何制作透明的覆盖层? - I have a video background bootstrap page. How can I make a transparent overlay? 如何使我的导航栏(具有透明背景)在视差滚动网页中浮动/重叠背景? - How can I make my navigation bar (which has transparent background) to float/overlap my background in a parallax-scrolling webpage? Babylon JS - 如何制作透明背景 - Babylon JS - How can I make the transparent background 如何使默认的音频播放器背景透明 - How can I make the default audioplayer background be transparent 如何使元素的背景透明? - How can I make an element's background transparent? 我正在使用 Mamp,所以我可以将 phpAdmin 用于我的 react native 项目。 如何修复根文件夹 - I'm using Mamp so I can use phpAdmin for my react native project. How can I fix the root folder 尝试编译我的反应项目时收到大量错误。 我完全不知道这意味着什么或如何开始修复它 - Recieving an influx of errors when trying to complie my react project. I quite literally have no idea what it means or how to begin to fix it 我的引导页面上有视频背景-如何使其“固定”? - I have a video background on my bootstrap page - how can I make it “fixed”? 滚动后如何使透明导航栏具有背景色? - How Do I Make Transparent Navbar Have Background Color After Scroll? 如何使引导程序Navbar背景透明地淡入网页 - How to make bootstrap Navbar background have a transparent fade into the webpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM