CSS 没有体现在react js中
CSS is not refleted in react js
我正在尝试覆盖 reacstrap 组件以及一些 html 元素。但是 CSS 没有反映在 those.Here 是组件上。
const DeleteKpiModal = ({isOpen, kpiToDelete, toggle, handleDeleteKpi}) => (
<Modal isOpen={isOpen} toggle={() => toggle(null)}>
<ModalBody>
<h2 className="heading-style">Delete KPI?</h2>
<p className="delete-content">
Are you sure you want to delete this?
Once deleted, the data will be lost and will not be able to be recovered.
</p>
</ModalBody>
<ModalFooter className="display-button">
<Button className="delete-button" size="md" block onClick={() => handleDeleteKpi(kpiToDelete)}>Delete</Button>
<Button className="cancel-button" color="secondary" size="md" block onClick={() => toggle(null)}>Cancel</Button>
</ModalFooter>
<style jsx>{styles}</style>
</Modal>
)
这里是 Css。忘记这里的导入我正在使用 sass/scss 这样做。
const styles = scss`
@import "bootstrap-extended/jsx-import";
$bg-red: #e04c33;
.delete-button{
background-color: $bg-red;
color:#fff;
}
.delete-content{
borderBottom:1px dashed #dce1e5;
paddingBottom:3rem;
}
.heading-style{
color: $bg-red;
}
.cancel-button{
backgroundColor:#fff;
color:#047adc;
border:2px solid #047adc;
marginLeft:0;
}
.display-button{
display:initial;
padding-top:0;
}
`
我做错的地方请帮助。
我是这样申请的。我为上部组件制作了一个 class 并像那样使用它。
<style jsx global>{`
$bg-red: #e04c33;
.delete-kpi-modal{
.delete-button{
background-color: $bg-red;
color:#fff;
}
.delete-content{
border-bottom:1px dashed #dce1e5;
padding-bottom:3rem;
}
.heading-style{
color: $bg-red;
text-align:center;
}
.cancel-button{
background-color:#fff;
color:#047adc;
border:2px solid #047adc;
margin-left:0;
}
.display-button{
display:initial;
padding-top:0;
}
}
`
}
</style>
这行得通
我正在尝试覆盖 reacstrap 组件以及一些 html 元素。但是 CSS 没有反映在 those.Here 是组件上。
const DeleteKpiModal = ({isOpen, kpiToDelete, toggle, handleDeleteKpi}) => (
<Modal isOpen={isOpen} toggle={() => toggle(null)}>
<ModalBody>
<h2 className="heading-style">Delete KPI?</h2>
<p className="delete-content">
Are you sure you want to delete this?
Once deleted, the data will be lost and will not be able to be recovered.
</p>
</ModalBody>
<ModalFooter className="display-button">
<Button className="delete-button" size="md" block onClick={() => handleDeleteKpi(kpiToDelete)}>Delete</Button>
<Button className="cancel-button" color="secondary" size="md" block onClick={() => toggle(null)}>Cancel</Button>
</ModalFooter>
<style jsx>{styles}</style>
</Modal>
)
这里是 Css。忘记这里的导入我正在使用 sass/scss 这样做。
const styles = scss`
@import "bootstrap-extended/jsx-import";
$bg-red: #e04c33;
.delete-button{
background-color: $bg-red;
color:#fff;
}
.delete-content{
borderBottom:1px dashed #dce1e5;
paddingBottom:3rem;
}
.heading-style{
color: $bg-red;
}
.cancel-button{
backgroundColor:#fff;
color:#047adc;
border:2px solid #047adc;
marginLeft:0;
}
.display-button{
display:initial;
padding-top:0;
}
`
我做错的地方请帮助。
我是这样申请的。我为上部组件制作了一个 class 并像那样使用它。
<style jsx global>{`
$bg-red: #e04c33;
.delete-kpi-modal{
.delete-button{
background-color: $bg-red;
color:#fff;
}
.delete-content{
border-bottom:1px dashed #dce1e5;
padding-bottom:3rem;
}
.heading-style{
color: $bg-red;
text-align:center;
}
.cancel-button{
background-color:#fff;
color:#047adc;
border:2px solid #047adc;
margin-left:0;
}
.display-button{
display:initial;
padding-top:0;
}
}
`
}
</style>
这行得通