🧐[问题]有没有覆写现有类名样式的能力?
ByYogi opened this issue · comments
像Emotion css 可以通过css
属性覆写 div 里面的 p
标签和.cls2
样式;
用 adtd-style 怎么做到这一点?
import { css } from '@emotion/react'
const color = 'white'
export default () => (
<div
css={css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
p {
color: red;
}
.cls2{ color: blue;}
&:hover {
color: ${color};
}
`}
>
<p>Another</p>
<div class="cls2">Another 2 </div>
Hover to change color.
</div>
)
可以通过 cx
函数实现以className
实现样式覆写
import { cx,css } from 'antd-style';
const color = 'white'
export default () => (
<div
className={cx(css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
p {
color: red;
}
.cls2{ color: blue;}
&:hover {
color: ${color};
}
`)}
>
<p>Another</p>
<div class="cls2">Another 2 </div>
Hover to change color.
</div>
)