Prevent zoom on smartphone/tablet with Bootstrap 3

Asked

Viewed 6,229 times

5

I use Bootstrap 3 in my projects and have a question.

I would like to know how to prevent the zoom on smartphones and tablets, that zoom that is done with the movement of "tweezers" or with double touch.

This keeps the Bootstrap responsive behavior, i.e., the page width should remain fixed at the same screen size.

I know this is possible because there are web applications out there (e.g., Facebook, Twitter) that also prevent mobile zooming.

  • Do you have any code to show your attempts?

  • In fact only the <meta name="viewport" content="user-scalable=no">, no need to use maximum-scale=1.

  • @Renan Correto. I found two articles that talk about the tag and I’ll leave it here for those who are interested: https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag and http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho

1 answer

7


You can disable zoom options on mobile devices by adding user-scalable=no to the meta tag viewport.

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

This disables zooming, so users will only be able to scroll and your site will look a little more like a native application. This nay is recommended for all sites, so use with caution!

See more on official documentation.

  • 1

    Perfect friend! Thank you very much. =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.