admin管理员组文章数量:1291029
I am using the jQuery plugin called Bootboxjs for my modals.
This is how I run the code:
bootbox.dialog({
title: '<i class="fa fa-thumbs-up"/></i> View Likes',
buttons: {
close: {
label: '<i class="fa fa-times"></i> Close',
className: "btn-danger",
callback: function() {
// Close the modal
}
}
},
message: '<span name="getLikesResults"></span>'
});
I am making a plugin for a project and I don't want this to affect existing modal styles but I need to make this specific modal scrollable when the content reaches the max height.
.modal .modal-body {
max-height: 420px;
overflow-y: auto;
}
How could I apply the above CSS to just this bootbox
modal?
I am using the jQuery plugin called Bootboxjs for my modals.
This is how I run the code:
bootbox.dialog({
title: '<i class="fa fa-thumbs-up"/></i> View Likes',
buttons: {
close: {
label: '<i class="fa fa-times"></i> Close',
className: "btn-danger",
callback: function() {
// Close the modal
}
}
},
message: '<span name="getLikesResults"></span>'
});
I am making a plugin for a project and I don't want this to affect existing modal styles but I need to make this specific modal scrollable when the content reaches the max height.
.modal .modal-body {
max-height: 420px;
overflow-y: auto;
}
How could I apply the above CSS to just this bootbox
modal?
-
Instead of
.modal .modal-body
try applying it to.bootbox-body
. – mccannf Commented Aug 2, 2014 at 21:07
2 Answers
Reset to default 3You can try this
.bootbox-dialog .modal-body {
max-height: 420px;
overflow-y: auto;
}
Check out these examples
http://bootboxjs./examples.html
Inspect the modals on the examples they each have a custom class. In the first example class bootbox-alert. In the second example class bootbox-confirm.
If your code follows the examples. Your code should have a class called bootbox-dialog on the modal.
The bootbox docs show you can add a custom class name.
http://bootboxjs./documentation.html
This is a good write up on how the css selectors work.
http://css-tricks./how-css-selectors-work/
I would suggest you to add class only to your modal that'll have all the required styles. You can do this way:
bootbox.dialog({
title: '<i class="fa fa-thumbs-up"/></i> View Likes',
buttons: {
close: {
label: '<i class="fa fa-times"></i> Close',
className: "btn-danger",
callback: function() {
// Close the modal
}
}
},
message: '<span name="getLikesResults"></span>'
}).addClass('bootboxDanger');
.bootboxDanger{
max-height: 420px;
overflow-y: auto;
}
本文标签: javascriptjQuery add CSS Class to bootbox Modal DynamicallyStack Overflow
版权声明:本文标题:javascript - jQuery add CSS Class to bootbox Modal Dynamically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741510716a2382590.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论