A viewport is a rectangular viewing region in computer graphics, or a term used for optical components. It has several definitions in different contexts.A viewport is a region of the screen used to display a portion of the total image to be shown. Also it can be a group of regions that together make one layout.
Questions tagged [viewport]
2818 questions
1012
votes
17 answers
How to get the browser viewport dimensions?
I want to provide my visitors the ability to see images in high quality, is there any way I can detect the window size?
Or better yet, the viewport size of the browser with JavaScript? See green area here:

Alix Axel
- 151,645
- 95
- 393
- 500
474
votes
20 answers
How do you disable viewport zooming on Mobile Safari?
I've tried all three of these to no avail:

MetaGuru
- 42,847
- 67
- 188
- 294
365
votes
28 answers
Get viewport/window height in ReactJS
How do I get the viewport height in ReactJS? In normal JavaScript I use
window.innerHeight()
but using ReactJS, I'm not sure how to get this information. My understanding is that
ReactDOM.findDomNode()
only works for components created. However…

Jabran Saeed
- 5,760
- 3
- 21
- 37
350
votes
10 answers
How to increase the vertical split window size in Vim
:vsplit (short form: :vs) split the Vim viewport vertically. :30vs splits the viewport, making the new window 30 characters wide. Once this 30 char window is created, how would one change it's size to 31 or 29?
With horizontal windows Ctrl-W +…

molicule
- 5,481
- 3
- 29
- 40
314
votes
7 answers
Using jQuery To Get Size of Viewport
How do I use jQuery to determine the size of the browser viewport, and to redetect this if the page is resized? I need to make an IFRAME size into this space (coming in a little on each margin).
For those who don't know, the browser viewport is not…

Volomike
- 23,743
- 21
- 113
- 209
245
votes
32 answers
Detect viewport orientation, if orientation is Portrait display alert message advising user of instructions
I am building a website specifically for mobile devices. There is one page in particular which is best viewed in landscape mode.
Is there a way to detect if the user visiting that page is viewing it in Portrait mode and if so, display a message…

Dan
- 10,171
- 7
- 38
- 31
188
votes
7 answers
HTML5 Canvas 100% Width Height of Viewport?
I am trying to create a canvas element that takes up 100% of the width and height of the viewport.
You can see in my example here that is occurring, however it is adding scroll bars in both Chrome and FireFox. How can I prevent the extra scroll…

aherrick
- 19,799
- 33
- 112
- 188
188
votes
3 answers
What does the shrink-to-fit viewport meta attribute do?
I'm having trouble finding documentation for this. Is it Safari specific?
There was a recent bug in iOS 9 (here), the solution to which is adding shrink-to-fit=no to the viewport meta.
What does this code do?

755
- 2,991
- 3
- 20
- 34
187
votes
22 answers
Overflow-x:hidden doesn't prevent content from overflowing in mobile browsers
I have a website here.
Viewed in a desktop browser, the black menu bar properly extends only to edge of the window, since the body has overflow-x:hidden.
In any mobile browser, whether Android or iOS, the black menu bar displays its full width,…

Indigenuity
- 9,332
- 6
- 39
- 68
186
votes
19 answers
disable viewport zooming iOS 10+ safari?
I've update my iPhone 6 plus to iOS 10 beta version and just found that in mobile safari, you can zoom any webpages by double tapping or pinching IGNORE the user-scalable=no code in the meta tag. I don't know whether it's a bug or feature. If it's…

Sam Su
- 6,532
- 8
- 39
- 80
119
votes
6 answers
Using jquery to get element's position relative to viewport
What's the proper way to get the position of an element on the page relative to the viewport (rather than the document). jQuery.offset function seemed promising:
Get the current coordinates of the first element, or set the
coordinates of every…

DA.
- 39,848
- 49
- 150
- 213
106
votes
4 answers
jquery $(window).width() and $(window).height() return different values when viewport has not been resized
I am writing a site using jquery that repeatedly calls $(window).width() and $(window).height() to position and size elements based on the viewport size.
In troubleshooting I discovered that I am getting slightly different viewport size reports in…

Manca Weeks
- 1,143
- 3
- 11
- 11
104
votes
4 answers
What's the point of 'meta viewport user-scalable=no' in the Google Maps API
I'm using the Google Maps JavaScript API V3 and the official examples always have you include this meta tag:
Most of the 3rd-party examples I've seen also do it. I wrote a…

Ian Dunn
- 3,541
- 6
- 26
- 44
101
votes
3 answers
Can I change the viewport meta tag in mobile safari on the fly?
I have an AJAX app built for mobile Safari browser that needs to display different types of content.
For some content, I need user-scalable=1 and for other ones, I need user-scalable=0.
Is there a way to modify the value of the content attribute…

Pepper
- 2,932
- 4
- 25
- 26
97
votes
12 answers
Disable Pinch Zoom on Mobile Web
I want to disable Pinch and Zoom on Mobile devices.
What configuration should I add to the viewport ?
Link : http://play.mink7.com/n/dawn/

Harsha M V
- 54,075
- 125
- 354
- 529