【发布时间】:2021-02-02 22:23:44
【问题描述】:
我正在尝试在我的 react js 应用程序中设置一个 GIF 背景图像,但我尝试了不同的方法,它们中的任何一个似乎都有效。有什么建议吗?
这是我的完整代码,我的问题在创建背景图像的第一行(backgroundH)
import React from "react";
import "../../src/App.css";
import "./Home.css";
import backgroundH from "../Images/SyncLink Home v.4.gif";
import { Button } from "react-bootstrap";
import { Link } from "react-router-dom";
function Home() {
return (
<div
class="bk_Img"
style={{
backgroundImage: "url(" + backgroundH + ")",
backgroundSize: "cover",
height: "100vh",
}}
>
<ol className="homeButtons">
<Link to="/LogIn" style={{ textDecoration: "none", color: "white" }}>
<li>
<Button className="btn--secondary" variant="primary">
LOG IN
</Button>
</li>
</Link>
<Link to="/SignUp" style={{ textDecoration: "none", color: "white" }}>
<li>
<Button className="btn--secondary" variant="primary">
SIGN UP
</Button>
</li>
</Link>
<Link
to="/ContactUs"
style={{ textDecoration: "none", color: "white" }}
>
<li>
<Button className="btn--secondary" variant="primary">
HELP
</Button>
</li>
</Link>
</ol>
</div>
);
}
export default Home;
【问题讨论】:
-
这个问题,与 react 无关——可能 gif 路径已损坏(检查您的页面)。
标签: javascript css reactjs visual-studio frontend