如何让我的文本显示在视频上(React)
我正在尝试在占用 100 vh/vw 的视频上添加文本,它大约位于我页面的一半位置。我似乎找不到使用内联样式将文本放在视频上的好方法。
我尝试了 top: "0" 但这只是将其带到整个网页的顶部,而不是它所在的 div 的顶部。
有人有任何提示吗?这是我的代码!
function About() {
return (
<div>
<div
className="parallaxImg"
style={{
backgroundAttachment: "fixed",
backgroundImage: "url(" + Beach + ")",
display: "flex",
objectFit: "cover",
justifyContent: "center",
alignItems: "center",
width: "100%",
height: "30vh",
zIndex: "1",
opacity: "80%",
backgroundRepeat: "no-repeat",
}}
>
<div class="center">
<h1
style={{
opacity: "100%",
color: "white",
}}
>
About{" "}
</h1>
</div>
</div>
<br/>
//The video starts here. Above was just a parallax header thing.
<div>
<video
loop
autoPlay
muted
id="video"
style={{
height: "100vh",
width: "100vw",
objectFit: "cover",
position: "relative",
pointerEvents: "none",
}}
>
<source src={Video} type="video/mp4" />
</video>
<div
style={{
color: "green",
position: "absolute",
textAlign: "center",
alignItems: "center",
justifyContent: "center",
}}
>
<p>
Aloha, I’m a front-end developer located on the island of Oahu, Hawaii. I have a serious passion for technology and learning all the things to make technology work for me.
</p>
<p>
When i’m not tinkering with the latest gadget, you can find me surfing Hawaii's waves, on a beach volleyball court or vacationing at a ski resort breaking another collar bone.
</p>
<p>
Other than sports and technology, I am very much a family person and faith oriented. Both keep me grounded and make me want to be the best version of myself.
</p>
<p>
Overall, im trying to meet like-minded people who can mentor me to make me a stronger Web Developer, a smarter employee and a more wholesome and selfless person in general.
</p>
</div>
</div>
</div>
);
这是我所看到的屏幕截图。(必须裁剪掉大部分图片,因为文件太大)
这是我的github 如果有帮助的话。
I'm trying to add Text over a video that takes up 100 vh/vw, and it's about halfway down my page. I can't seem to find a good way to use Inline Styles to put the text over the video.
I tried top: "0" but that just brings it to the top of the entire webpage, not the top of the div that it's in.
Does anyone have any tips? Here is my code!
function About() {
return (
<div>
<div
className="parallaxImg"
style={{
backgroundAttachment: "fixed",
backgroundImage: "url(" + Beach + ")",
display: "flex",
objectFit: "cover",
justifyContent: "center",
alignItems: "center",
width: "100%",
height: "30vh",
zIndex: "1",
opacity: "80%",
backgroundRepeat: "no-repeat",
}}
>
<div class="center">
<h1
style={{
opacity: "100%",
color: "white",
}}
>
About{" "}
</h1>
</div>
</div>
<br/>
//The video starts here. Above was just a parallax header thing.
<div>
<video
loop
autoPlay
muted
id="video"
style={{
height: "100vh",
width: "100vw",
objectFit: "cover",
position: "relative",
pointerEvents: "none",
}}
>
<source src={Video} type="video/mp4" />
</video>
<div
style={{
color: "green",
position: "absolute",
textAlign: "center",
alignItems: "center",
justifyContent: "center",
}}
>
<p>
Aloha, I’m a front-end developer located on the island of Oahu, Hawaii. I have a serious passion for technology and learning all the things to make technology work for me.
</p>
<p>
When i’m not tinkering with the latest gadget, you can find me surfing Hawaii's waves, on a beach volleyball court or vacationing at a ski resort breaking another collar bone.
</p>
<p>
Other than sports and technology, I am very much a family person and faith oriented. Both keep me grounded and make me want to be the best version of myself.
</p>
<p>
Overall, im trying to meet like-minded people who can mentor me to make me a stronger Web Developer, a smarter employee and a more wholesome and selfless person in general.
</p>
</div>
</div>
</div>
);
Here is a screen shot of what I'm seeing.(had to crop out most of the picture because it was too big of a file)
Here is my Github if it helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论