How to automatically resize the width and height of the div with JavaScript?

I see this done especially for sliders. The width and height properties are provided on the javascript side and are automatically responsive in the best way. What kind of function can we do this with? How to find the best height in javascript based on browser size?

To set the size of an element with JavaScript, there needs to be an event that triggers the function. In your case, you probably want the Window resize event.

I know that event but ı don’t know how ı can write a function.

If you are talking about using JS for responsive design I would advise against it, unless you absolutely have to use it. In most cases all you need is CSS.

Can you give a more specific usage example of what you are trying to do?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.