Make toastr alerts look like bootstrap alerts

后端 未结 3 977
天命终不由人
天命终不由人 2020-12-30 02:29

I\'d like to make toastr\'s popup look the same as, or very close to, Bootstrap alerts. How can I do this?

3条回答
  •  一向
    一向 (楼主)
    2020-12-30 02:55

    To make them the same as bootstrap 3.2.0, i used a combination of the selected answer - although alert-error should be alert-danger - and this gist, which replaces the icons with fontawesome icons

    https://gist.github.com/askehansen/9528424

    To make them look exactly the same i also

    • set the opacity of the toasts to 1
    • changed the title and message colour to match bootstrap

    css is

    #toast-container > div {
        opacity: 1;
        -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
        filter: alpha(opacity=100);
    }
    
    #toast-container > .alert {
        background-image: none !important;
    }
    
    #toast-container > .alert:before {
        position: fixed;
        font-family: FontAwesome;
        font-size: 24px;
        float: left;
        color: #FFF;
        padding-right: 0.5em;
        margin: auto 0.5em auto -1.5em;
    }
    
    #toast-container > .alert-info:before {
        content: "\f05a";
    }
    #toast-container > .alert-info:before,
    #toast-container > .alert-info {
        color: #31708f;
    }
    
    #toast-container > .alert-success:before {
        content: "\f00c";
    }
    #toast-container > .alert-success:before,
    #toast-container > .alert-success {
        color: #3c763d;
    }
    
    #toast-container > .alert-warning:before {
        content: "\f06a";
    }
    #toast-container > .alert-warning:before,
    #toast-container > .alert-warning {
        color: #8a6d3b;
    }
    
    #toast-container > .alert-danger:before {
        content: "\f071";
    }
    #toast-container > .alert-danger:before,
    #toast-container > .alert-danger {
        color: #a94442;
    }
    

提交回复
热议问题