javascript - React Native 中以 hr 为中心的图标

标签 javascript css react-native

我想设计一条水平线,其顶部有一个图标,例如 this one ,但是在 native react 中。朝着以下方向的事情:

<View style={{}}>
  <View style={{}}>
  <Image style={{}} source={}/>
</View>

enter image description here 我该怎么做?

最佳答案

试试这个代码

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

export default class App extends Component {
  render() {
    return (
      <View style={{ paddingTop: 100, alignItems: 'center' }}>
        <View style={{ borderBottomColor: '#bdbdbd', borderBottomWidth: 1, width: '90%' }} />
        <View style={{ position: 'relative' }}>
          <Image
            style={styles.image}
            source={{
              uri: 'http://www.cgbconstrucciones.com/en/templates/rt_clarion/images/icons/green-leaf-icon.png',
            }}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  image: {
    width: 40,
    height: 40,
    position: 'absolute',
    top: -20,
    left: -20,
    backgroundColor: '#fff'
  }
});

在此处查看演示 https://snack.expo.io/@raajnadar/absolute-position

关于javascript - React Native 中以 hr 为中心的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49632734/

相关文章:

javascript - Jquery移动: Disable "tap to toggle" fixed header and footer

javascript - CSS - 如何格式化内容数据标题文本

html - Css 中心 ul li inside div

css - 使用CSS设置div的绝对位置

react-native - 如何在 react-native 0.64.0 (rc4) 中使用 react 17 的新 JSX 转换?

reactjs - react native this.setState 不起作用

javascript - 文本框 -> 立即开始输入而不是单击文本框

javascript - 如何在 JavaScript 中将价格转换为有效的价格格式?

html - 为什么 flexbox 只限制 chrome 中的 child 高度?

android - 如何从 React Native Android 模块访问 Activity?