Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery将CSS类动态添加到引导框模式_Javascript_Jquery_Css_Twitter Bootstrap_Bootbox - Fatal编程技术网

Javascript jQuery将CSS类动态添加到引导框模式

Javascript jQuery将CSS类动态添加到引导框模式,javascript,jquery,css,twitter-bootstrap,bootbox,Javascript,Jquery,Css,Twitter Bootstrap,Bootbox,我正在为我的modals使用名为Bootboxjs的jQuery插件 以下是我运行代码的方式: bootbox.dialog({ title: '<i class="fa fa-thumbs-up"/></i>&nbsp;&nbsp;View Likes', buttons: { close: { label: '<i class="fa fa-times"></i>&

我正在为我的modals使用名为Bootboxjs的jQuery插件

以下是我运行代码的方式:

bootbox.dialog({
    title: '<i class="fa fa-thumbs-up"/></i>&nbsp;&nbsp;View Likes',
    buttons: {
        close: {
            label: '<i class="fa fa-times"></i>&nbsp;&nbsp;Close',
            className: "btn-danger",
            callback: function() {

                // Close the modal

            }

        }
    },
    message: '<span name="getLikesResults"></span>'
});
如何将上述CSS仅应用于此
引导框
模式?

您可以尝试此功能

.bootbox-dialog .modal-body {
    max-height: 420px;
    overflow-y: auto;
}
看看这些例子

检查示例上的modals,每个modals都有一个自定义类。在第一个示例中,类引导框警报。在第二个示例中,类引导框确认

如果您的代码遵循示例。 您的代码应该在模式上有一个名为bootboxdialog的类

bootbox文档显示您可以添加自定义类名

这是一篇关于css选择器如何工作的好文章


我建议您只在模态中添加具有所有必需样式的类。 您可以这样做:

bootbox.dialog({
    title: '<i class="fa fa-thumbs-up"/></i>&nbsp;&nbsp;View Likes',
    buttons: {
        close: {
            label: '<i class="fa fa-times"></i>&nbsp;&nbsp;Close',
            className: "btn-danger",
            callback: function() {

                // Close the modal

            }

        }
    },
    message: '<span name="getLikesResults"></span>'
}).addClass('bootboxDanger');

尝试将其应用于
.bootbox body
,而不是
.modal.modal body
bootbox.dialog({
    title: '<i class="fa fa-thumbs-up"/></i>&nbsp;&nbsp;View Likes',
    buttons: {
        close: {
            label: '<i class="fa fa-times"></i>&nbsp;&nbsp;Close',
            className: "btn-danger",
            callback: function() {

                // Close the modal

            }

        }
    },
    message: '<span name="getLikesResults"></span>'
}).addClass('bootboxDanger');
.bootboxDanger{
    max-height: 420px;
    overflow-y: auto;
}