【发布时间】:2018-06-25 13:41:45
【问题描述】:
我正在尝试在 React 中设置背景图片,但它只覆盖了大约 75% 的高度。
似乎组件没有占据所有高度。
解决办法是什么?
在 index.js 中:
ReactDOM.render(<Login />, document.getElementById('root'));
在 index.css 中:
html, body, .Login-component {
height: 100%;
}
在 Login.js 中:
render() {
return (
<div className='Login-component'>
);
}
在 Login.css 中
.Login-component {
background: url(../static/login-bg.jpg) no-repeat center center fixed;
background-size: cover;
}
最终结果:Screen shot
【问题讨论】:
-
你能显示一些代码吗?
-
没有显示你尝试过的问题太宽泛了,这个问题有很多解决方案。
-
编辑:添加代码:)
标签: reactjs