ionic-framework - 我们可以自定义离子吐司关闭按钮吗?
问题描述
我正在尝试为离子吐司按钮添加背景颜色,但未能成功。我在 global.scss 中尝试了下面的 css。有人能告诉我我怎样才能做到这一点。?
.positive-toast-message {
--min-width: 60%;
--background: #bde7c3;
--color: black;
--button-color: black;
.toast-button {
--background: red !important;
background: white !important;
background-color: blue !important;
}
}
创建 Toast 后,它会正确应用“positive-toast-message”css
解决方案
如果你想这样做,那么你应该使用 css 类。像这样叫吐司
const toast = await this.toastCtrl.create({
message: 'Please Fill all fields',
duration: 30000,
position: 'top',
cssClass: 'toast-bg'
});
toast.present();
然后转到 global.scss 文件并将这个类放在那里
.toast-bg {
--background: blue;
--button-color: #ffffff;
}
这应该有效。在 global.scss 的 css 类中将颜色更改为您想要的任何颜色
推荐阅读
- c - Functions sem_post, sem_wait and sleep
- cloudera - 在 Cloudera 中设置集群时与服务器通信时出错
- json - 如何使用jq过滤具有混合类型元素的数组
- maven - Is there any automated way to get artifact download URL back from artifactory?
- android - Android:适配器的viewconvert为空,但我通过了正确的布局
- java - 如何使用两个不同长度的数组在表中打印值
- tensorflow - Tensorflow memory consumption is different on VM
- python - Co occurance matrix for tfidf vectorizer for top 2000 words
- java - The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket
- sql - How to dynamically create and populate a local temp table (when the table headers are unknown)?