[Flexbox] Use Flex to Scale Background Image

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Flexbox] Use Flex to Scale Background Image相关的知识,希望对你有一定的参考价值。

In this lesson we will use Flexbox to scale a background image to fit on the screen of our React Native application.

 

import React, { Component } from react;
import {AppRegistry, StyleSheet, Text, View, Image} from react-native;

export default class general extends Component {
  render() {
    return (
      <Image source={require("./cat.jpg")} style={styles.container}>
        <Text>A good looking cat</Text>
      </Image>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    width: null,
    height: null,
    alignItems: "center",
    justifyContent: "center"
  }
})

AppRegistry.registerComponent(general, () => general);

 

以上是关于[Flexbox] Use Flex to Scale Background Image的主要内容,如果未能解决你的问题,请参考以下文章

FCC---CSS Flexbox: Apply the flex-direction Property to Create a Column in the Tweet Embed

CSS3 display:flex和display:box有啥区别

聊聊Flexbox布局中的flex的演算法

CSS3 Flexbox:显示:box vs. flexbox vs. flex

CSS3 Flexbox:显示:box vs. flexbox vs. flex

CSS3 Flexbox:显示:box vs. flexbox vs. flex