Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 地点<;文本>;在中间和左端_Javascript_Html_Css_Reactjs_React Native - Fatal编程技术网

Javascript 地点<;文本>;在中间和左端

Javascript 地点<;文本>;在中间和左端,javascript,html,css,reactjs,react-native,Javascript,Html,Css,Reactjs,React Native,我有一个屏幕,我想将第一个主文本项(过滤器)放在屏幕的正中间,而第二个项(全部删除)应该放在的右端。他们两个应该在同一条线上 我不希望使用填充/边距,因为它们在不同的手机尺寸中可能会有所不同。我已经在使用文本对齐,但它不适合我 export default function App() { return ( <View style={styles.container}> <View style={styles.topTextContainer}>

我有一个屏幕,我想将第一个主文本项
(过滤器)
放在屏幕的正中间,而第二个项
(全部删除)
应该放在的右端。他们两个应该在同一条线上

我不希望使用填充/边距,因为它们在不同的手机尺寸中可能会有所不同。我已经在使用文本对齐,但它不适合我


export default function App() {
  return (
    <View style={styles.container}>
       <View style={styles.topTextContainer}>
            <Text style={styles.filterText}>Filter</Text>
            <Text style={styles.deleteAllText}>All Delete</Text>
          </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
},
  topTextContainer: {
    paddingTop: moderateScale(35),
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
  filterText: {
    fontSize: moderateScale(15),
    fontWeight: 'bold',
    textAlign: 'center'
  },
  deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    marginLeft: moderateScale(75),
  },
});

导出默认函数App(){
返回(
滤器
全部删除
);
}
const styles=StyleSheet.create({
容器:{
弹性:1,
},
topTextContainer:{
paddingTop:中等比例(35),
flexDirection:'行',
为内容辩护:“中心”,
对齐项目:“居中”,
},
过滤器文本:{
字体大小:中等大小(15),
fontWeight:'粗体',
textAlign:“中心”
},
删除所有文本:{
字体大小:中等大小(13),
颜色:“#363636”,
fontWeight:'300',
边缘左侧:中等比例(75),
},
});

Codesandbox:

您可以使用删除按钮的绝对位置,并将其设置为右:0,如下所示

deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: 'absolute',
    right: 0
  }

另一个选项是对两个文本使用
marginLeft:“auto”
,这可能会有帮助,但不会将第一个文本保持在中间。

您可以使用删除按钮的绝对位置,并将其设置为右:0,如下所示

deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: 'absolute',
    right: 0
  }

另一种选择是使用<代码> MulnLeLe:“Auto/<代码>两种文本,它们可以帮助但不保留第一个中心。

< P>精确的MLLD是指在屏幕宽度和高度的中间,像这样:

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  topTextContainer: {
    paddingTop: moderateScale(35),
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    height: "100%"
  },
  filterText: {
    fontSize: moderateScale(15),
    fontWeight: 'bold',
    textAlign: 'center'
  },
  deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: "absolute",
    right: 0
    //marginLeft: moderateScale(75),
  },
});
如果是,则应设置高度:“100%”

如果您想让它位于中间上方,那么这应该是正确的方法:

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  topTextContainer: {
    paddingTop: moderateScale(35),
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
  filterText: {
    fontSize: moderateScale(15),
    fontWeight: 'bold',
    textAlign: 'center'
  },
  deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: "absolute",
    right: 0
    //marginLeft: moderateScale(75),
  },
});


<设置>代码>删除文本>代码>代码>位置:绝对< /代码>和代码>右:0 < /代码>

< p>精确的MLLD,您的意思是在屏幕宽度和高度的中间,像这样:

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  topTextContainer: {
    paddingTop: moderateScale(35),
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    height: "100%"
  },
  filterText: {
    fontSize: moderateScale(15),
    fontWeight: 'bold',
    textAlign: 'center'
  },
  deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: "absolute",
    right: 0
    //marginLeft: moderateScale(75),
  },
});
如果是,则应设置高度:“100%”

如果您想让它位于中间上方,那么这应该是正确的方法:

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  topTextContainer: {
    paddingTop: moderateScale(35),
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
  filterText: {
    fontSize: moderateScale(15),
    fontWeight: 'bold',
    textAlign: 'center'
  },
  deleteAllText: {
    fontSize: moderateScale(13),
    color: '#363636',
    fontWeight: '300',
    position: "absolute",
    right: 0
    //marginLeft: moderateScale(75),
  },
});


设置
deleteAllText
位置:绝对
右:0

这在codesandbox上起作用,但在我的应用程序中不起作用。在那里,它会将所有删除文本拖到上面或下面的一行。该应用程序在屏幕上是否有任何其他组件?@Jnl当您使用绝对值时,它会移到顶部,因为您在父级中有一个填充顶部,您必须将顶部设置为:35以及右侧:0。不知何故,这在codesandbox上有效,但在我的应用程序中不起作用。在那里,它会将所有删除文本拖到上面或下面一行。该应用程序在屏幕上是否有任何其他组件?@Jnl当您使用绝对值时,它会移到顶部,因为您在父级中有一个填充顶部,您必须将顶部设置为35,同时将右侧设置为0