如何像我们在sass中那样在react原生中使用样式?
.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);
}
因为我试过用同样的技术,但似乎行不通
发布于 2018-07-10 03:48:25
Css伪类不能在原生反应中工作,但是如果你想让你的样式看起来尽可能的接近css,我推荐使用像Styled Components这样的东西。它既适用于web,也适用于原生react。
发布于 2021-10-25 21:29:52
您可以使用样式化组件轻松创建伪类
示例:
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%;
}
`;
https://stackoverflow.com/questions/51249854
复制相似问题