我对“无CSS”这个概念感到困惑,但我理解它的好处。我只想在屏幕中央放置一个按钮,但我还不理解React中的样式如何工作。这是我的代码:
var tapSpeed = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Tap me as fast as you can!
</Text>
<View style={styles.button}>
!
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFCCCC'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10
},
button: {
textAlign: 'center',
color: '#ffffff',
marginBottom: 7,
border: 1px solid blue,
borderRadius: 2px
}
});
border: '1px solid blue',
- Austin GrecolineItems
属性值更改为'stretch'
。 - vhs