【发布时间】:2021-07-15 17:27:52
【问题描述】:
试图改变 Toast 容器的背景颜色,下面的代码假设这样做。 我不知道我错过了什么,但它不起作用......
这是我尝试过的:
.toastError {
margin-top: 15rem;// this works
&.Toastify__toast--error {
background: #bd362f !important;// this is is not...
}
}
反应组件:
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
..
return (
<ToastContainer position="top-center"
className={styles.toastError}
autoClose={4000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
rtl={false}
pauseOnFocusLoss
draggable
pauseOnHover
/>
margin-top 影响组件但不能改变颜色,该元素在浏览器中如下所示:
我需要做什么才能让它工作?
【问题讨论】:
-
你忘记了&符号和类
&.Toastify__toast--error之间的空格@ -
@Martin 谢谢,但不起作用
标签: reactjs sass react-css-modules