简体   繁体   English

如何删除自举程序的模态背景的淡入淡出

[英]How can I remove the fade out of bootstrap's modal-backdrop

I want to show the user a series of modals, not just one. 我想向用户展示一系列模态,而不仅仅是一个。 My goal is to have the first modal fade in with a backdrop, and leave the backdrop up for the second and third modals without it fading out. 我的目标是使第一个模态随着背景淡入,并为第二个和第三个模态保留背景而不会褪色。 The backdrop should then fade out after the third modal. 然后,背景应在第三个模式后淡出。 Essentially I want the first modal to appear with the backdrop - then the second and third modals appear over the same backdrop as the first and second modals fade out. 本质上,我希望第一个模态与背景一起出现-然后第二个和第三个模态在第一个和第二个模态消失时出现在相同的背景上。 Then the third modal should disappear with the backdrop. 然后,第三个模态应随着背景消失。

I've tried the following code, the modal remains, but the second backdrop won't fire as it seems it waits for the previous modal-backdrop to disappear before firing: 我尝试了以下代码,模态仍然存在,但是第二个背景不会触发,因为它似乎在等待之前的模态背景消失后才触发:

  $('.modal-backdrop.fade').css({
    opacity: 0.8
  });

I then tried removing the 'fade' class from the backdrop but that doesn't work either. 然后,我尝试从背景中删除“ fade”类,但这也不起作用。

The code that triggers the following modal is as follows: 触发以下模式的代码如下:

  $modalOne.on('hidden', function (e) {
    $modalTwo.modal('show');
  }

I like to gamble. 我喜欢赌博。

 $('.modal-backdrop.fade').css({
     'background-color': 'rgba(0,0,0,0.8)'
 });

Give that a whirl - FYI this is to test a theory of mine. 打个招呼-仅供参考,这是为了测试我的理论。 If it works, use this instead of opacity . 如果可行,请使用它代替opacity The last digit in that set of 4 numbers is the alpha level ( essentially its opacity ). 这组4个数字中的最后一位数字是alpha级别本质上是其不透明度 )。 The others are red , green and blue of course. 其他当然是红色绿色蓝色

Well based on the answer from Deryck, I was toying around it and came to this solution that worked for me. 基于Deryck的回答,我一直在玩弄它,并得出了对我有用的解决方案。

 $('.modal-backdrop').css({
     'position': 'relative'
 });

Check position relative on some element or z-index i had z-index: 0 on container element and this what cause the issue. 检查相对于某个元素或z-index的位置,我在容器元素上具有z-index:0,这是引起问题的原因。 (Designers can't live with them, can't leave without them :)) (设计师不能与他们同住,不能没有他们:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM