C
C
colorkid2016-08-30 10:13:21
JavaScript
colorkid, 2016-08-30 10:13:21

Responsive layout with JavaScript. How it's done?

Hello. Faced such a task that there is an online store and a bunch of different blocks, important information, etc. ( colorkid.ru/stolberi/). The whole thing needs to be made adaptive. And I started having problems ...
When the screen is reduced, I transfer blocks along the tree through appendChild and then a complete kotovasiya occurs. Not only do the blocks that need to be transferred accumulate a bunch and they again need to be returned to their original position when the screen is expanded, but the function that does all this works every other time. Really! view function


function f(){....}
window.onload = function() {
window.onresize = f;
f()
}

worked through time and then through 2. Ie. when the screen changed, this function called the f function, which all transferred elements across the dom, it did not work stably.
In general, I suffered with this approach and decided that I would do adaptability only through media queries, let it be easier, but more reliable.
And how are you with this case? In general, does anyone use JS to make the layout adaptive-fluid? Where to read something, how it is done according to the mind?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dima Pautov, 2016-08-30
@bootd

Why are you carrying them all? Why for adaptive layout js? Yes, there are times when you need it. But the way you use it is not correct. Why is everything not done through css?

G
gleendo, 2016-08-30
@evgeniy8705

I will do it only through media queries , let it be easier , but more reliable

So don't mess around with JS. All responsiveness is done with CSS

I
Ivan, 2016-08-30
@LiguidCool

See articles on how to make all sorts of Bootsrap grids (not how to use, but how to implement).

S
sazhyk, 2016-08-30
@sazhyk

Use Bootstrap , Luke!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question