RN stylesheet

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

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

/*


 1.  HTML5以;结尾
 React以,结尾
 2.  HTML5中key  value 都不加引号
 React中属于JavaScript对象,key的名字不能出现"-",需要使用驼峰命名法,如果value为字符串,需要加引号
 3.  HTML5中,value如果是数字,需要带单位
 React中不需要带单位


 */
/*
 拼接样式,在数组中,位置居后的样式要比位置居前的优先级高,越后写的优先级越高
 */
/*
 内联样式,用大括号括起来

 */

class LessonStyle extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={[styles.top, styles.border]}>
        </View>
        <View style={[styles.bottom, styles.border, {borderWidth: 5}]}>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  //外层View
  container: {
    marginTop: 25,
    marginLeft: 30,
    backgroundColor: 'red',
    width: 300,
    height: 400
  },
  //上层View
  top: {
    backgroundColor: 'green',
    width: 280,
    height: 250,
    margin: 10,
    // borderWidth: 3,
    // borderColor: 'black'
  },
  //下层View
  bottom: {
    backgroundColor: 'yellow',
    width: 280,
    height: 110,
    margin: 10,
    //borderWidth: 3,
    //borderColor: 'black'
  },
  //拼接样式,公共的部分
  border: {
    borderWidth: 3,
    borderColor: 'black'
  }
});

AppRegistry.registerComponent('SytleSheet', () => LessonStyle);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值