首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >帧运动覆盖react-bootstrap

帧运动覆盖react-bootstrap
EN

Stack Overflow用户
提问于 2020-08-30 06:15:19
回答 2查看 667关注 0票数 1

我正在构建一个使用gatsby/react/react-bootstrap/framer-motion的网站。我有一个框架运动覆盖我的反应引导css的问题?我不想把所有的响应性都重新定义到这些元素中,我想知道有没有办法让这两个库彼此配合得很好??这似乎是一个令人头疼的试图使帧运动响应…我可能只是设计不同的视口,但idk。

下面是我的代码:

代码语言:javascript
复制
import React from "react";
import 'bootstrap/dist/css/bootstrap.min.css';
import './styles.scss';
import { Image, Container, Row } from 'react-bootstrap';
import CamcoNavbar from '../components/camconavbar.js';
import BackgroundImage from '../../static/Untitled-1.jpg';
import CClogo from '../../static/CamCo(white).png'
import { motion } from 'framer-motion';

const Home = () => {
  return (
    <div>
      <CamcoNavbar />

      <Container>
        <motion.img className="cclogo" key={CClogo} src={CClogo} initial={{opacity: 0}} animate={{opacity: 1}} transition={{duration: 3}}/>
      </Container>

      
      <motion.img className="header-image" key={BackgroundImage} src={BackgroundImage} initial={{x: -250}} animate={{x: 1000}} transition={{duration: 60, repeat: Infinity}}/>



    </div>
  )
}

export default Home

下面是我的css:

代码语言:javascript
复制
@import "~bootstrap/scss/bootstrap";

body {
  background-color: black;
}

.nav-item {
  padding-left: 20px;
  padding-right: 20px;
}

.nav-item a {
  text-decoration: none;
  letter-spacing: 5px;
  font-weight: 300;
  font-size: 12px;
  color: white;
}

.nav-item a:hover {
  text-decoration: none;
  color: #64a0c2;
}

.carousel-item {
  background-color: blue;
  width: 400px;
  height: 400px;
}

button.navbar-toggler {
  justify-content: center;
}

.header-image {
  object-fit: cover;
  display: inline-block;
  min-width: 100%;
  min-height: 100%;
  width: 120%;
  height: 120%;
  position: fixed;
  top: 0;
  z-index: -4;
}

.cclogo {
  position: relative;
  top: 50%;
  left: 50%;
z-index: 2;

}

p, h1, h2, h3, h4, li {
  color: white;
}

非常感谢任何帮助!

EN

回答 2

Stack Overflow用户

发布于 2020-09-30 19:40:41

尝试将运动标记引用为道具,并使用常规的html标记:

代码语言:javascript
复制
<img as={motion.img}>
票数 1
EN

Stack Overflow用户

发布于 2021-04-15 19:12:48

Framer不覆盖css样式。

您需要npm i framer-motionnpm i react-bootstrap

所有这些库都不覆盖全局样式。问题隐藏在您的自定义css

注意您在import中使用的组件。

示例:如果可以使用“容器”css类,为什么要从react bootstrap导入{ Image,Container,Row }?你只需要从react-bootstrap导入bootstrap.css并使用css而不是常量。

附注:“react-bootstrap”中的一些元素不能正常工作,例如,看看this example

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63652277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档