【发布时间】:2019-02-26 05:34:45
【问题描述】:
我正在使用带有徽标和 2 个输入的 React Native 创建基本登录:
//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Image } from 'react-native';
// create a component
class Login extends Component {
render() {
const imageURL = require('./images/CircleLogo.png');
return (
<View style={styles.container}>
<View style={styles.loginContainer}>
<Image resizeMode="contain" style={styles.logo} source={imageURL} />
</View>
<View style={styles.formContainer}>
<LoginForm />
</View>
</View>
);
}
}
// define your styles
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'aliceblue',
},
loginContainer:{
alignItems: 'center',
flexGrow: 1,
justifyContent: 'center'
},
logo: {
position: 'absolute',
width: '70vw',
height: '70vw',
maxWidth: 300
}
});
//make this component available to the app
export default Login;
如您所见,我正在使用 vw 和 vh css 测量值。
这适用于网络,但不适用于 iOS 或 Android。
有没有人对处理vw 和vh 测量有好的建议?
旁注:react 似乎接受了here 所见的百分比,我可能会恢复。但我的问题具体与vw 和vh 测量有关。
【问题讨论】:
标签: css reactjs react-native