N
N
Natalia2019-05-24 13:13:34
css
Natalia, 2019-05-24 13:13:34

How to stretch image to fit modal window in fancybox?

The task is next.
There is an image slider. When you click on a slider image, the image opens in a modal window.
The peculiarity is that not all pictures are initially as large as you want.
Therefore, the task is to stretch insufficiently large pictures to the desired size, fixing, for example, the size of the modal window.
How can I do that?
Now fancybox is installed and working.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Usachov, 2019-05-24
@rockfeeler

You can try this with a callback:

$(".fancy").fancybox({
    afterShow: function () {
        this.height = $(window).height();
        this.width = 'auto'
    }
});

Accordingly, the dimensions of the modal window can also be configured in advance (see the documentation for fansy) and work with pictures inside it through pure css.

N
Natalia ivanova, 2019-06-03
@Natalia_ai

Thanks for the answer.
It didn't work through the callback.
I coped with the forces of the css.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question