无论如何我可以告诉 React 组件全屏显示并且背景颜色为绿色。下面的代码不会使高度为 100%。
var rootStyle = {
backgroundColor : 'green',
color : 'white',
height : '100%'
}
class App extends Component {
render() {
return (
<div style={rootStyle}>
<Poll />
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
Nic*_*las 11
使 div 为视口高度的 100%。
var rootStyle = {
height: '100vh',
min-height : '100vh'
}
Run Code Online (Sandbox Code Playgroud)
问题不在于React。React 只是获取页面的 HTML。问题是你的body元素只和它的内容一样大。解决这个问题的一种方法是将其添加到您的 css 中:
html, body {
width: 100%;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
这里有类似的东西
| 归档时间: |
|
| 查看次数: |
24510 次 |
| 最近记录: |