React+Ant-design 在Modal中的组件内使用css变量能找到,但是在Modal外使用css变量提示找不到
.small-upload {
position: fixed;
width: 200px;
height: 60px;
background: white;
border: var(--ant-line-width) solid var(--ant-color-primary-hover);
border-radius: var(--ant-border-radius-lg);
//height: 100px;
}
<div className="small-upload">
<Progress percent={getProgress()} format={getProgressText} size="small"/>
<ExpandAltOutlined style={{ fontSize: 20, color: token.token.colorPrimary }}/>
</div>
<Modal>
<div className="small-upload">
<Progress percent={getProgress()} format={getProgressText} size="small"/>
<ExpandAltOutlined style={{ fontSize: 20, color: token.token.colorPrimary }}/>
</div>
</Modal>
同一个组件,在Modal内部能找到css变量,在外部却不行,是什么原因呢
Modal内的效果
Modal外的效果
局部作用域的CSS变量只能在定义它们的选择器或规则内部被访问。例如,仅在特定类中使用的变量应定义在该类选择器内