bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Modal without fade transition has opaque black backdrop

Open AREALFAKE opened this issue 13 years ago • 24 comments

When I open a modal window on Bootstrap 3 the backdrop of the rest of the page becomes black (or very dark grey). I found that the modal-backdrop was responsible for this as it didn't have an opacity set.

I used the simplest example with opening a modal window through the use of

<a data-toggle="modal" href="#" data-target="#modal-1">open</a>

referring to my model with id modal-1 on the same page.

.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  background-color: #333333;
  opacity:0.8; // I ADDED THIS LINE 
    }
}

Maybe it is intential to have a dark full color backdrop, but it looks crappy and takes away the visibility of the drop shadows of the modal itself.

AREALFAKE avatar Jul 28 '13 21:07 AREALFAKE

I get a translucent medium gray as the backdrop in the current docs: http://twbs.github.io/bootstrap/javascript/#modals-examples

What browser and OS are you using?

cvrebert avatar Jul 28 '13 21:07 cvrebert

I use Windows Vista (I know..) and tested in IE 9 and Firefox 22

AREALFAKE avatar Jul 28 '13 21:07 AREALFAKE

Do you experience this problem in the docs too, or just on your own page?

cvrebert avatar Jul 28 '13 21:07 cvrebert

Only on my own page so far. It seems my pages uses the .modal-backdrop class and when I analyse the docs it seems to be using hte .modal-open class

AREALFAKE avatar Jul 29 '13 07:07 AREALFAKE

@AREALFAKE Have you tried class="modal fade" ? Let me know.

r1c4r60 avatar Jul 29 '13 11:07 r1c4r60

See the html example page below.

http://jsfiddle.net/N3PhG/3/

AREALFAKE avatar Jul 29 '13 13:07 AREALFAKE

I took the liberty of porting your example to a jsFiddle.

cvrebert avatar Jul 29 '13 19:07 cvrebert

OK, I can now repro your problem with the example. But it works in the docs, so the problem should be in your markup somewhere...

cvrebert avatar Jul 29 '13 19:07 cvrebert

Problem is the lack of .fade on the div.modal. I'll fix the docs...

cvrebert avatar Jul 29 '13 20:07 cvrebert

Many thanks! Would have taken me ages to find such a little thing!

AREALFAKE avatar Jul 29 '13 20:07 AREALFAKE

Shouldn't the modal work even without the fade class (less the transition)?

In modals.less, I don't see a default opacity style set for the .modal-backdrop. This causes the backdrop issue seen here.

Note that the modal works [without transition] as expected, but the backdrop is fully opaque. This is obviously undesirable and also different from BS2.

claviska avatar Jul 31 '13 21:07 claviska

I think in the Bootstrap 2 we had the option to remove the "fade" and the opacity in the modal backdrop still worked correctly. Can removing the fade still respect the opacity?

mattruma avatar Aug 03 '13 19:08 mattruma

When I delete these styles from bootstrap.css the modal opacity and fade work normally.

Line 5889 .fade { opacity: 0; -webkit-transition: opacity 0.15s linear; transition: opacity 0.15s linear; } .fade.in { opacity: 1; }

1nspire avatar Aug 26 '13 16:08 1nspire

Was this fixed in v3.0.0? I am using the version from bootstrapcdn:

//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css

The modal backdrops are still completely black.

julianlam avatar Sep 05 '13 00:09 julianlam

@julianlam The CDN's no-icons versions are fubared due to #10030.

cvrebert avatar Sep 05 '13 00:09 cvrebert

Thanks for pointing me in the right direction! :+1:

julianlam avatar Sep 05 '13 00:09 julianlam

@julianlam See also https://github.com/netdna/bootstrap-cdn/issues/166

cvrebert avatar Sep 05 '13 00:09 cvrebert

I had the same problem, I also removed the same code as @1nspire and now I get the faded background.

MarcusThatsMe avatar Sep 08 '13 17:09 MarcusThatsMe

Another fix is to add fade to this style in your custom.css. Line 5098 in the bootstrap.css file.

.modal-backdrop.fade.in { opacity: 0.5; filter: alpha(opacity=50); }

1nspire avatar Sep 08 '13 20:09 1nspire

I still have this issue with netdna host CSS.

cchantep avatar Oct 04 '13 13:10 cchantep