css - 如何更改整个页面的背景?
问题描述
所以我使用 React native 并且我的大多数页面都有问题,我似乎无法将整个背景颜色更改为所有元素的统一颜色。IE:
import React, { Component } from "react";
import { View, Text, FlatList, ActivityIndicator } from "react-native";
import { List, ListItem, SearchBar } from "react-native-elements";
class Animals extends Component {
render() {
return (
<View
style={{
flexDirection: 'row',
height: 100,
padding: 20,
backgroundColor: 'gray'
}}>
<Text>Hello World!</Text>
</View>
);
}
}
export default Animals;
如何使背景颜色适用于整个屏幕?
解决方案
更改样式以%
在适用的地方添加。保持它们关闭将使 html 将其解释为px
在您的情况下为 100 像素。https://reactjs.org/docs/dom-elements.html
import React, { Component } from "react";
import { View, Text, FlatList, ActivityIndicator } from "react-native";
import { List, ListItem, SearchBar } from "react-native-elements";
class Animals extends Component {
render() {
return (
<View
style={{
flexDirection: 'row',
height: '100%',
padding: '20px',
backgroundColor: 'gray'
}}>
<Text>Hello World!</Text>
</View>
);
}
}
export default Animals;
编辑:更新样式
推荐阅读
- powershell - 从 Jenkins 到变量 powershell 的 IP 地址输入
- python - 作为等差数列一部分的最小数字之和
- javascript - Semantic-ui 表格菜单未按预期工作
- c++ - c ++中的全局范围变量未正确初始化
- .net-core - .NET Core 3.1 GetService 返回 null
- python - 一个函数的 Python 生成线程
- python - 泡菜数据未加载
- c# - C# 类型安全的 JSON 行反序列化
- c# - SSL/TLS (HTTPS) 的 C# 目标主机名始终为空
- clojure - 为什么不能在 deftest 周围应用 with-redefs?