首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >React Native :类似css的样式设置之后

React Native :类似css的样式设置之后
EN

Stack Overflow用户
提问于 2018-07-10 00:10:34
回答 2查看 14K关注 0票数 5

如何像我们在sass中那样在react原生中使用样式?

代码语言:javascript
复制
.pro_image:after {
        content: '';
        position: absolute;
        border-radius: 100%;
        top: -10px;
        left: -10px;
        bottom: -10px;
        right: -10px;
        border: 10px solid rgba(255, 255, 255, 0.075);
    }

因为我试过用同样的技术,但似乎行不通

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-10 03:48:25

Css伪类不能在原生反应中工作,但是如果你想让你的样式看起来尽可能的接近css,我推荐使用像Styled Components这样的东西。它既适用于web,也适用于原生react。

票数 7
EN

Stack Overflow用户

发布于 2021-10-25 21:29:52

您可以使用样式化组件轻松创建伪类

示例:

代码语言:javascript
复制
import styled from "styled-components";
import theme from "./theme";

export const HoverLinedLink = styled.div`
  a {
    position: relative;
    padding: 10px 0px;
    margin: 0px 15px;
    color: #fff;
    font-weight: bold;
  }

  a:hover {
    text-decoration: none;
  }

  a:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 0;
    height: 3px;
    background: '#d00; // Red
    transition: 250ms;
  }

  a:hover:after {
    width: 100%;
  }
`;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51249854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档