我正在构建一个使用gatsby/react/react-bootstrap/framer-motion的网站。我有一个框架运动覆盖我的反应引导css的问题?我不想把所有的响应性都重新定义到这些元素中,我想知道有没有办法让这两个库彼此配合得很好??这似乎是一个令人头疼的试图使帧运动响应…我可能只是设计不同的视口,但idk。
下面是我的代码:
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:
@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;
}非常感谢任何帮助!
发布于 2020-09-30 19:40:41
尝试将运动标记引用为道具,并使用常规的html标记:
<img as={motion.img}>发布于 2021-04-15 19:12:48
Framer不覆盖css样式。
您需要npm i framer-motion和npm i react-bootstrap。
所有这些库都不覆盖全局样式。问题隐藏在您的自定义css中
注意您在import中使用的组件。
示例:如果可以使用“容器”css类,为什么要从react bootstrap导入{ Image,Container,Row }?你只需要从react-bootstrap导入bootstrap.css并使用css而不是常量。
附注:“react-bootstrap”中的一些元素不能正常工作,例如,看看this example。
https://stackoverflow.com/questions/63652277
复制相似问题