flex布局居中无效果注意是否设置了宽度

<View style={{display:'flex',marginTop:JDDevice.getRpx(),backgroundColor:'#fff',flexDirection:'row',height:JDDevice.getRpx(),alignItems:'center'}}>
<JDTouchable style={styles.wraper} onPress={()=>{this._jumpShiYou()}}>
<View style={styles.imagesPox}><JDImage source={require('../images/petroleum.png')} style={styles.imgBox}/></View>
<View style={styles.word}><JDText>中国石油</JDText></View>
</JDTouchable>
<View style={styles.line}></View>
<JDTouchable style={styles.wraper} onPress={()=>{this._jumpShiHua()}}>
<View style={styles.imagesPox}><JDImage source={require('../images/chemical.png')} style={styles.imgBox}/></View>
<View style={styles.word}><JDText>中国石化</JDText></View>
</JDTouchable>
<View style={styles.line}></View>
<JDTouchable style={styles.wraper} onPress={()=>{this._judgeLogin()}}>
<View style={styles.imagesPox}><JDImage source={require('../images/card.png')} style={styles.imgBox}/></View>
<View style={styles.word}><JDText>壳牌</JDText></View>
</JDTouchable>
</View>

View 是flex布局;JDTouchable是flex:1;设置居中, 里面的两个View必须提供宽度,才能居中!
flex布局居中无效果注意是否设置了宽度的更多相关文章
- flex布局justify-content属性和align-items属性设置
前言: flex最常用的就是justify-content和align-items了,这里把这两个属性介绍下,大家更多关于flex布局可以查看阮一峰的日志,写的非常清楚! 阮一峰flex布局的日志:h ...
- flex布局 居中
display:flex;justify-content: center;检查侧轴是否居中,比如古代竖着写字,检查字是否在每条竹简的中央. display:flex;align-items: cent ...
- 使用css中的flex布局弹性手风琴效果
不多说,直接上代码. <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- Flex布局摆脱float带来的布局问题
完整文章地址http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?utm_source=tuicool 使用浮动(float)的一个比较疑惑 ...
- flex布局-弹性布局
弹性布局当前应用的非常广泛,特别是移动端,记得第一次用reactNative 写代码的时候是最开始真正接触Flex布局.1.首先最外层的容器需要指定为display:flex;由于flex的兼容版本还 ...
- 谈谈flex布局实现水平垂直居中
我们在这要谈的是用flex布局来实现水平和垂直居中.随着移动互联网的发展,对于网页布局来说要求越来越高,而传统的布局方案对于实现特殊布局非常不方便,比如垂直居中.所以09年,W3C 提出了一种新的方案 ...
- 详解纯css实现瀑布流(multi-column多列及flex布局)
瀑布流的布局自我感觉还是很吸引人的,最近又看到实现瀑布流这个做法,在这里记录下,特别的,感觉flex布局实现瀑布流还是有点懵的样子,不过现在就可以明白它的原理了 1.multi-column多列布局实 ...
- 纯css实现瀑布流(multi-column多列及flex布局)
瀑布流的布局自我感觉还是很吸引人的,最近又看到实现瀑布流这个做法,在这里记录下,特别的,感觉flex布局实现瀑布流还是有点懵的样子,不过现在就可以明白它的原理了 1.multi-column多列布局实 ...
- Flex 布局 (两个div居中自适应 宽度变小变一列,宽度够就是两列)
https://www.runoob.com/w3cnote/flex-grammar.html display: flex; justify-content: center; align-items ...
随机推荐
- bzoj2301
题解: 莫比乌斯反演 再加上一个分块 然后和上一题差不多了 代码: #include<cstdio> #include<cmath> #include<algorithm ...
- 和的java程序
- unordered_map/unordered_set & unordered_multimap/unordered_multiset非关联容器
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- translclude
.transclude:true 启用transclude,启用以后,有两个地方会发生变化: ①.使用指令的元素内部的所有内容都会被保存起来.不妨先把这一段内容称为一坨. 比如指令元素是这样的: &l ...
- session会话示例
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- c/c++动态内存分配的区别
c中动态内存分配使用malloc和free. malloc指定需要分配的内存大小,分配成功则返回指向该内存的指针,不成功则返回空指针.返回的指针类型为void *,表示不确定指针所指内存存放的数据类型 ...
- Linux(centos) 下curl模拟Http get / post请求 [ curl ]
一.get请求 curl "http://www.baidu.com" 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地 curl -i "http:// ...
- vue中使用sass 做减法计算
首先确认已安装sass依赖, yarn指令:yarn add sass-loader, style中写法如下: 注意calc(100% - 200px); 之间有两个空格的,
- python Django rest-framework 序列化步骤
django-rest-framework,是一套基于Django 的 REST 框架,是一个强大灵活的构建 Web API 的工具包.本文介绍一下 django-rest-framework 的简单 ...
- Python 爬虫的工具列表大全
Python 爬虫的工具列表大全 这个列表包含与网页抓取和数据处理的Python库.网络 通用 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pyc ...