【发布时间】:2019-05-15 13:46:40
【问题描述】:
我想将我的按钮放在屏幕的左下方。我尝试过使用bottom: 0 和left: 0,但这并没有做任何事情。我研究了一下,发现我需要设置position: 'absolute'。但是,当我这样做时,我的按钮会完全消失。
如何通过屏幕左下角的按钮定位?
这是我的代码:
import React, { Component } from 'react';
import { Button,Alert, TouchableOpacity,Image } from 'react-native'
import {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
class Project extends Component {
render() {
return (
<View style={{backgroundColor: '#375D81', flex: 1}}>
<View style = {styles.container}>
<TouchableOpacity style = {styles.buttonText} onPress={() => { Alert.alert('You tapped the button!')}}>
<Text>
Button
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
main: {
backgroundColor: 'blue'
},
container: {
alignItems: 'center',
},
buttonText: {
borderWidth: 1,
padding: 25,
borderColor: 'black',
backgroundColor: '#C4D7ED',
borderRadius: 15,
bottom: 0,
left: 0,
width: 100,
height: 100,
position: 'absolute'
}
});
AppRegistry.registerComponent('Project', () => Project);
【问题讨论】:
标签: css react-native flexbox