我目前使用以下语法将状态颜色嵌入 jsx。
<div className="preview-box" style={{backgroundColor:this.state.color}}>
有没有办法使用 css 中的亮化功能来做这样的事情?
<div className="preview-box" style={{backgroundColor: lighten(this.state.color, 15%)}}>
最佳答案
您可以使用SCSS
获取backgroundColor: lighten(this.state.color, 15%)
CSS 部分
$awesome-blue: #2196F3;
$width: 100%;
$height: 500px;
.box {
background: lighten($awesome-blue, 10%); /* As your need */
width: $width;
height:$height;
display:flex;
align-items:center;
justify-content:center;
}
我只是发布了一个例子来说明它是如何工作的,它可能会对你有所帮助
关于css - 将 Lighten Css 特性嵌入到 Jsx/React,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44512011/