question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flex: 1 - react-native-web

See original GitHub issue

The main style does not work for react-native-web

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    backgroundColor: 'gold',
    justifyContent: 'center'
  },
  text: {
    alignItems: 'center',
    fontSize: 24
  }
})

export default props => (
  <View style={styles.container}>
    <View style={{ position: 'absolute', top: '50%', right: '15%' }}>
      <Text style={{ fontSize: 80, textAlign: 'right' }} >
        Home
      </Text>
    </View>
  </View>

Now so 2018-05-22 18 58 24

It must be so 2018-05-22 19 00 37

System information

  • OS: macOS
  • Browser (if applies) all
  • Version of Next.js: 6.0.3

the solution height: '100%' does not fit

How to be?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
dcalhouncommented, May 23, 2018

Instead of adding display: flex to the body, target the <div id="__next" /> element with CSS. The below is updated code from the RNW example.

// _document.js
// Force Next-generated DOM elements to fill their parent's height.
const normalizeNextElements = `
  #__next {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
`
2reactions
timneutkenscommented, May 23, 2018

I’m going to close this as @dcalhoun is right. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-web · Issue #4450 · vercel/next.js - Flex: 1 - GitHub
The parent element of your container is not a flex element, so flex: 1 has no impact on the container height. Unrelated, when...
Read more >
Layout with Flexbox - React Native
flex will define how your items are going to “fill” over the available space ... The red view uses flex: 1 , the...
Read more >
React Native Stylesheet: what does {flex:1} do? - Stack Overflow
Here's a CodePen that demonstrates that flex: 1 the way React Native examples use it doesn't do anything in CSS:.
Read more >
Using flexbox in React Native - LogRocket Blog
Developing a mobile app in React Native? Use Flexbox, a CSS tool that enables you to build layouts to fit multiple screen sizes....
Read more >
Flexbox: How to use it to style thoroughly in React Native
In short, CSS Flexible Box Layout, commonly known as React native flex 1, is a CSS 3 web layout model. It is likewise...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found