如何使用React Native样式表?
Without wasting much time, a style sheet as commonly known in a CSS is an object or block of code of many styling properties and values which is applied in a code when called.
在不浪费大量时间的情况下,CSS中通常已知的样式表是具有许多样式属性和值的代码的对象或代码块,该对象或代码块在调用时应用于代码中。
It's almost the same as in CSS but has a little different regarding some naming conventions.
它几乎与CSS中的相同,但在某些命名约定方面有所不同。
In react native, a style sheet is created by initiating a constant, assigning it to a styleSheet.create function as seen below.
在react native中,样式表是通过启动一个常量并将其分配给styleSheet.create函数创建的 ,如下所示。
The style sheet is then invoked or called by passing an inline style reference using a single curly brace.
然后通过使用单个花括号传递内联样式引用来调用或调用样式表。
Open your App.js file and type the following,
打开您的App.js文件,然后输入以下内容:
import * as React from 'react';
import { Text, View, StyleSheet, Button, TextInput } from 'react-native';
export default function App() {return (
<View style={styles.box}>
<View style={styles.container}>
<TextInput style={styles.myinput} />
<Button title="GO" />
</View>
</View>
);
}
const styles = StyleSheet.create({box: {padding: 50,
},
container: {flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
myinput: {Width: '80%',
borderBottomColor: 'black',
padding: 10,
borderBottomWidth: 1,
},
});
Output
输出量
Thanks for coding with me! See you @ the next article. Feel free to drop a comment or question. God Bless You!
感谢您与我编码! 下次见。 随意发表评论或问题。 上帝祝福你!
翻译自: https://www.includehelp.com/react-js/how-to-use-react-native-style-sheet.aspx
如何使用React Native样式表?相关推荐
- Zephyr 简介:用于 React Native 的 Tailwind CSS
使用纯 CSS 构建复杂的 Web 应用程序可能是一项艰巨的挑战. 因此,开发人员倾向于使用 Bootstrap 和 Tailwind CSS 等流行的样式库来缩短开发周期. 与 Web 上的样式类似 ...
- React Native初探
React Native初探 转自:博客园 叶小钗 前言 很久之前就想研究React Native了,但是一直没有落地的机会,我一直认为一个技术要有落地的场景才有研究的意义,刚好最近迎来了新的APP ...
- React Native Styling:样式化的组件,Flexbox布局等
React Native provides an API for creating stylesheets and styling your components: StyleSheet. React ...
- React Native StyleSheet 样式属性
2019独角兽企业重金招聘Python工程师标准>>> 简介 React Native StyleSheet 提供一系类的对样式(类似css)属性. 其中包括 Layout 布局相关 ...
- React Native之Props(属性)和State(状态)和简单样式简单使用
1 Props(属性)和State(状态)和简单样式简单使用App.js代码如下 /*** Sample React Native App* https://github.com/faceboo ...
- react 组件添加样式_如何通过4个简单的步骤将CSS模块样式表添加到React组件
react 组件添加样式 Let's say you'd like to add a CSS Modules Stylesheet to your project. You can find Crea ...
- [React Native Android 安利系列]样式与布局的书写
欢迎大家收看react-native-android系列教程,跟着本系列教程学习,可以熟练掌握react-native-android的开发,你值得拥有: https://segmentfault.c ...
- React Native之样式
样式 React Native 不实现 CSS,而是依赖于 JavaScript 来为你的应用程序设置样式.这是一个有争议的决定,你可以阅读那些幻灯片,了解背后的基本原理. 声明样式
- React Native应用中的样式
React Native应用中的样式 RN中样式与CSS名称类似,但是本质上不同 -- RN应用中没有浏览器内核!!! 例如:RN中的组件不分"行内"."行内块" ...
最新文章
- MySQL5.7新特性:lossless replication 无损复制
- java练气期(1)----java高级(JDBC)
- PHP程序中时间戳,php 时间戳常用代码
- 中科大 计算机网络12 Web和HTTP
- c++-串的模式匹配
- Mybatis 批量操作总结
- 【build your own xxx】实现你自己的bind函数
- VMware安装Ubuntu 18.04虚拟机(镜像下载、硬盘分区、创建虚拟机、安装系统、桥接模式网络配置)
- 表单html遇到的问题及处理,Html表单中遇到的问题
- DOS下常用网络相关命令解释(华为培训资料)
- 我的实用设计模式之关于Policy-based design
- 网站速度优化模块HttpCompressionModule
- 谷歌浏览器无法登陆禅道问题
- phpwind测试之phpwind安装(二)
- 端午节公众号文章如何编辑排版可以吸粉引流
- 无人车之美——双舵轮运动分解与合成
- GRUB4DOS引导wim格式的pe
- linux虚拟机对外部sd卡格式化和分区
- 实验整理(一)——钓鱼邮件攻击实验
- os.path.dirname(os.path.realpath(__file__))函数