绝对和跳蚤反应本机

时间:2021-04-02 05:25:50

I would like to put a white bar which would take the all width at the bottom of the screen. To do so I thought about using absolute positioning with the inherited flexbox parameters.

我想在屏幕的底部放一个白色的条,条的宽度为所有。为此,我考虑使用继承的flexbox参数的绝对定位。

With the code following it renders something like this.

下面的代码将呈现如下内容。

Here is my code :

这是我的代码:

var NavigationBar = React.createClass({
  render: function() {
    return(
    <View style={navigationBarStyles.navigationBar}>
      //Icon 1, Icon 2...
    </View>
    );
  }
});

var Main = React.createClass({
  render: function() {
    return(
      <View style={mainStyles.container}>
          <NavigationBar />
      </View>
    );
  }
});

var mainStyles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#456783',
  }
});

var navigationBarStyles = StyleSheet.create({
  navigationBar: {
    backgroundColor: '#FFFFFF',
    height: 30,
    position: 'absolute', 
    flexDirection: 'row',
    bottom: 0,
    justifyContent: 'space-between'
  },
});

I'm new in styling in CSS and not all the properties are available in React-Native. So any help is appreciated, thanks :)

我是CSS样式的新手,并不是所有的属性都可以使用。因此,我们非常感谢您的帮助,谢谢。

3 个解决方案

#1


91  

Ok, solved my problem, if anyone is passing by here is the answer:

好的,解决了我的问题,如果有人经过这里,答案是:

Just had to add left: 0, and top: 0, to the styles, and yes, I'm tired.

只需在样式上加上左:0和上:0,是的,我累了。

position: 'absolute',
left:     0,
top:      0,

#2


36  

The first step would be to add

第一步是添加

position: 'absolute',

then if you want the element full width, add

如果你想要全宽度的元素,添加。

left: 0,
right: 0,

then, if you want to put the element in the bottom, add

然后,如果要将元素放在底部,请添加

bottom: 0,
// don't need set top: 0

if you want to position the element at the top, replace bottom: 0 by top: 0

如果要将元素放在顶部,请将底部:0替换为顶部:0

#3


0  

This solution worked for me:

这个解决方案对我起了作用:

tabBarOptions: {
      showIcon: true,
      showLabel: false,
      style: {
        backgroundColor: '#000',
        borderTopLeftRadius: 40,
        borderTopRightRadius: 40,
        position: 'relative',
        zIndex: 2,
        marginTop: -48
      }
  }

#1


91  

Ok, solved my problem, if anyone is passing by here is the answer:

好的,解决了我的问题,如果有人经过这里,答案是:

Just had to add left: 0, and top: 0, to the styles, and yes, I'm tired.

只需在样式上加上左:0和上:0,是的,我累了。

position: 'absolute',
left:     0,
top:      0,

#2


36  

The first step would be to add

第一步是添加

position: 'absolute',

then if you want the element full width, add

如果你想要全宽度的元素,添加。

left: 0,
right: 0,

then, if you want to put the element in the bottom, add

然后,如果要将元素放在底部,请添加

bottom: 0,
// don't need set top: 0

if you want to position the element at the top, replace bottom: 0 by top: 0

如果要将元素放在顶部,请将底部:0替换为顶部:0

#3


0  

This solution worked for me:

这个解决方案对我起了作用:

tabBarOptions: {
      showIcon: true,
      showLabel: false,
      style: {
        backgroundColor: '#000',
        borderTopLeftRadius: 40,
        borderTopRightRadius: 40,
        position: 'relative',
        zIndex: 2,
        marginTop: -48
      }
  }