【发布时间】:2019-04-12 14:23:23
【问题描述】:
我正在尝试更改我的图像位置:已修复,但是它会更改图像的位置,我现在什至无法再看到它了...我在这里查看了几篇帖子,但找不到实体解决方案。有没有办法获得在不同窗口大小上调整大小的固定图像以及如何定位这个固定图像?
这是我的代码:
反应jsx:
...
<div className="home-root3" style={{backgroundImage: logo2}}>
<div className="bottom-left">word1</div>
<div className="bottom-right">word2</div>
<div className="top-center">word3</div>
</div>
...
CSS:
.home-root3 {
position: fixed;
background:no-repeat;
transform: translate(-50%, -50%);
left: 50%;
top: 50%;
/*background-position: 50% 50%;*/
/*background-size: contain;*/
}
【问题讨论】:
-
你能建立一个工作复现来显示你的问题吗?
-
在元素上使用 position: fixed 会将其从页面流中移除,因此它可能隐藏在其他内容之后,但我们需要查看 HTML 的其余部分
标签: javascript css reactjs image frontend