我想在 React Native 中为我的 child class 添加 CSS
I want to add CSS for my child class in React Native
需要在 React Native 中回答。
<View>
<View className="parent1">
<Text>hello with green</Text>
</View>
<View>
<Text>hello with default color</Text>
</View>
</View>
现在我想将 CSS 添加到 Text 中,它有一个 parent classname 在 React Native[=32 中是 parent1 =].
如果要为父类名为 parent1 的文本标签提供 CSS,请按照以下步骤操作:
const stylesB = StyleSheet.create(
{
Text:
{
color: '#ffffff',
},
p:
{
color: '#ffffff',
},
h3:
{
color: '#ffffff',
},
h1:{
color: '#ffffff',
}
});
<View>
<View className="parent1" styles={stylesB}> //give styles as stylesB instead of giving stylesB.Text
<Text>hello with green</Text>
</View>
<View>
<Text>hello with default color</Text>
</View>
</View>
此更改将为具有类名 parent1 且标签为 Text、p、h1 和 h3 的标签的子项显示颜色白色。
需要在 React Native 中回答。
<View>
<View className="parent1">
<Text>hello with green</Text>
</View>
<View>
<Text>hello with default color</Text>
</View>
</View>
现在我想将 CSS 添加到 Text 中,它有一个 parent classname 在 React Native[=32 中是 parent1 =].
如果要为父类名为 parent1 的文本标签提供 CSS,请按照以下步骤操作:
const stylesB = StyleSheet.create(
{
Text:
{
color: '#ffffff',
},
p:
{
color: '#ffffff',
},
h3:
{
color: '#ffffff',
},
h1:{
color: '#ffffff',
}
});
<View>
<View className="parent1" styles={stylesB}> //give styles as stylesB instead of giving stylesB.Text
<Text>hello with green</Text>
</View>
<View>
<Text>hello with default color</Text>
</View>
</View>
此更改将为具有类名 parent1 且标签为 Text、p、h1 和 h3 的标签的子项显示颜色白色。