B
B
booyokkk2014-08-07 14:54:47
JavaScript
booyokkk, 2014-08-07 14:54:47

How to solve the problem with the script - stretching the image to fit the screen?

There is a script like this

c.onload = function () {
                var m, g, h, i, j, k, l;
                d.attr('src', e.album[f].link);
                m = b(c);
                d.width(c.width);
                d.height(c.height);
                if (e.options.fitImagesInViewport) {
                    l = b(window).width();
                    k = b(window).height();
                    j = l - e.containerLeftPadding - e.containerRightPadding - 20;
                    i = k - e.containerTopPadding - e.containerBottomPadding - 110;
                    if ((c.width > j) || (c.height > i)) {
                        if ((c.width / j) > (c.height / i)) {
                            h = j;
                            g = parseInt(c.height / (c.width / h), 10);
                            d.width(h);
                            d.height(g)
                        } else {
                            g = i;
                            h = parseInt(c.width / (c.height / g), 10);
                            d.width(h);
                            d.height(g)
                        }
                    } else {
                        d.width( parseInt(c.width / (c.height / i), 10));
                        d.height(i);
                    }
                }
                return e.sizeContainer(d.width(), d.height())
            };

It stretches the image from a small format to the size of the browser window, but it does not correctly read the width of the chrome browser on android portrait orientation, the picture goes beyond the window, please help to improve it somehow.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Ineshin, 2014-08-07
@IonDen

<body>
     <img src="url" style="width: 100%" />
</body>

What is wrong with this approach?

A
Alexander Taratin, 2014-08-08
@Taraflex

htmlbook.ru/css/background-size

R
Roman Pavlov, 2014-08-10
@JaneHolland

background-size: cover;
-o-background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question