How to make a background image of a modal window appear simultaneously with a modal window, not before?

Green

I have a modal window with a background image as a background css property. The problem is that the background image appears much faster than the modal itself. How to make make them appear simultaneously?

Here is my HTML code of the modal window:

<div class="modal" id="regModal" tabindex="-1" role="dialog" aria-labelledby="regModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-center modal-carpet" style="min-height: 400px;">
        <div class="modal-content"></div>
    </div>
</div>

Here is a class .modal:

.modal {  
    border: none !important;
    overflow: hidden;
    background-position: center;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    outline: 0;
    background: url('/img/carpet_simple.png') no-repeat fixed center;
}

And so background: url('/img/carpet_simple.png') no-repeat fixed center; appears instantaneously, much faster than the inner HTML code of the modal is rendered.

I tried this solution. It works but it is obviously not a good one. I just make a backgroung image appear 300ml later:

.pic {
    background: url('/img/carpet_simple.png') no-repeat fixed center;
}

$('.modal').on('shown.bs.modal', function() {    
    var timeOutId = setTimeout(function() {
        $("#regModal").addClass("pic");
        clearTimeout(timeOutId);
        delete(timeOutId);
    }, 280);
});

$('.modal').on('hide.bs.modal', function() {
    $("#regModal").removeClass("pic");
});

How to make a background appear simultaneously with a modal inner html code or at least a little after it? And without my solution.

Jordan.J.D

You can use javascript events for the modal. For example loaded.bs.modal;This event is fired when the modal has loaded content using the remote option.

$('#myModal').on('loaded.bs.modal', function (e) {
  // do something...
})

There are other events fired with the modal you can read about here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Twitter Bootstrap Modal - Grey background but no window

From Dev

How to create a modal window in pyqt?

From Dev

Getting the height of the image to set modal window size

From Dev

Display Modal window in Xamarin

From Dev

Display Image from DB in Modal Bootstrap Window

From Dev

Can you add a modal background to a Kendo window?

From Dev

Issue in displaying window as modal

From Dev

Lightswitch modal window

From Dev

how to make window.open pop up Modal?

From Dev

AngularJS - Closing Modal Window

From Dev

How to show modal window with image in Wicket

From Dev

Modal sheet is not attached to window

From Dev

How to close non-modal child window of modal window?

From Dev

How to display a modal Window in Vaadin?

From Dev

How to make this JavaScript popup window modal?

From Dev

How to make modal popup window in Vuejs?

From Dev

Twitter Bootstrap Modal - Grey background but no window

From Dev

Body background overlap with modal window how to tackle this?

From Dev

How to make a background image of a modal window appear simultaneously with a modal window, not before?

From Dev

Autoclose Modal Window? How to make modal window automatically close after a while?

From Dev

Modal Window: How can I set a different content for each modal?

From Dev

Morphing Modal Window broke all background fixed

From Dev

How to close non-modal child window of modal window?

From Dev

Video inside a bare CSS modal window autostarting before modal window is opened

From Dev

Bootstrap : Show modal window on image click in a loop

From Dev

Make a countdown timer display a modal window bootstrap

From Dev

Image in modal window with Ajax XMLHttpRequest

From Dev

How to make onchange event in javascript work from a modal window

From Dev

Link to launch modal window instead of image?

Related Related

  1. 1

    Twitter Bootstrap Modal - Grey background but no window

  2. 2

    How to create a modal window in pyqt?

  3. 3

    Getting the height of the image to set modal window size

  4. 4

    Display Modal window in Xamarin

  5. 5

    Display Image from DB in Modal Bootstrap Window

  6. 6

    Can you add a modal background to a Kendo window?

  7. 7

    Issue in displaying window as modal

  8. 8

    Lightswitch modal window

  9. 9

    how to make window.open pop up Modal?

  10. 10

    AngularJS - Closing Modal Window

  11. 11

    How to show modal window with image in Wicket

  12. 12

    Modal sheet is not attached to window

  13. 13

    How to close non-modal child window of modal window?

  14. 14

    How to display a modal Window in Vaadin?

  15. 15

    How to make this JavaScript popup window modal?

  16. 16

    How to make modal popup window in Vuejs?

  17. 17

    Twitter Bootstrap Modal - Grey background but no window

  18. 18

    Body background overlap with modal window how to tackle this?

  19. 19

    How to make a background image of a modal window appear simultaneously with a modal window, not before?

  20. 20

    Autoclose Modal Window? How to make modal window automatically close after a while?

  21. 21

    Modal Window: How can I set a different content for each modal?

  22. 22

    Morphing Modal Window broke all background fixed

  23. 23

    How to close non-modal child window of modal window?

  24. 24

    Video inside a bare CSS modal window autostarting before modal window is opened

  25. 25

    Bootstrap : Show modal window on image click in a loop

  26. 26

    Make a countdown timer display a modal window bootstrap

  27. 27

    Image in modal window with Ajax XMLHttpRequest

  28. 28

    How to make onchange event in javascript work from a modal window

  29. 29

    Link to launch modal window instead of image?

HotTag

Archive