Home > Back-end >  stretching component using left and right in react native
stretching component using left and right in react native

Time:10-11

I'm trying to stretch my <View> component using left and right

I know how to do it in html and css:

.testing{
  background-color: orange;
  position: absolute;
  left: 100px;
  right: 20px;
}
 <div class="testing"> 
  Hello there
 </div>

but how do I achieve the same result in react native?

Edit
I tried this but it doesn't work:

export default function App() {
  return (
    <View style={styles.container}>
      <View style={{ left: 100,right: 20,height:50,position: 'absolute', backgroundColor: 'orange'}}><Text>hello there</Text></View>
    </View>
  );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
      },
    });

CodePudding user response:

I tested your code and it's working for me. Try reinstalling and pasting your code in a new project

  • Related