ben*_*tzy 3 css modal-dialog twitter-bootstrap
通过将特定模式的ID设置为选择器,可以更改页面中多个模式之一的CSS。
例如:
.modal {
top: 0px;
margin-top: 240px;
...
}
Run Code Online (Sandbox Code Playgroud)
设置
#my_modal {
top: 0px;
margin-top: 240px;
...
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
如何更改仅#my_modal对应的模式背景的CSS ?
$('.modal').addClass('my_personal_stuff');
Run Code Online (Sandbox Code Playgroud)
工作,而
$('.modal-backdrop').addClass('my_personal_stuff');
Run Code Online (Sandbox Code Playgroud)
不起作用
为什么这样呢?
如何仅更改#my_modal的对应模式背景的CSS?
// Add an extra class to the modal backdrop to make it customizable
$('.modal--custom').on('show.bs.modal', function (e) {
setTimeout(function(){
$('.modal-backdrop').addClass('modal-backdrop--custom');
});
});
Run Code Online (Sandbox Code Playgroud)
这对我有用。看看这个jsFiddle。