\n 1<\/span>\n 2<\/span>\n 3<\/span>\n 4<\/span>\n 5<\/span>\n 6<\/span>\n 7<\/span>\n 8<\/span>\n\n It will not affect the actual value of viewport. In other words, for browsers on ordinary computers, there is no difference whether the viewport is set or not. <\/p>\n\n If the viewport is not set, change the viewport setting of the HTML content just now into annotation: Firefox on mobile phone displays as follows: <\/p>\n\n Enlarge the reduced part and you will see: <\/p>\n\n Since the default viewport width is 980, in order to fully display the horizontal content of the web page, it is automatically reduced to 0.4224 times in order to display the horizontal content of the web page. This multiple is larger than the default value of minimum-scale of 0.1, and will replace the minimum-scale setting. Even if the user reduces the display by himself, he can only reduce the display to 0.4224 times at most. <\/p>\n\n If you add the viewport settings back: The screen you see will be like this: <\/p>\n\n You can see that the width of the viewport (window.innerWidth) and the width of the device screen (window.screen.width) are the same, both are 414px. The webpage will be displayed with this width, and the zoom factor is 1. OK Clearly read the displayed web page content. Since this is the maximum zoom factor that can display horizontal content on a web page, it will also replace the default minimum-scale of 0.1. Users can only zoom the page to a minimum of 1 times. <\/p>\n\n If you keep the default zoom factor of 1, but don’t set the viewport width, like this: The actual result is the same as setting the width to device-width. <\/p>\n\n If you deliberately set the viewport width to 980: will be displayed as follows: <\/p>\n\n Since the width of the viewport is now wider than the screen, it will extend outside the screen during arrangement. You can also see from the actual displayed results that the screen width is indeed 980. <\/p>\n\n If you deliberately set the viewport width to be narrower than the screen, like: The browser will use the screen width as the lowest viewport width, so the display result will be the same as setting the width to device-width: <\/p>\n\n If you only set the viewport width, but not the initial-scale, like this: It will not affect the actual value of viewport. In other words, for browsers on ordinary computers, there is no difference whether the viewport is set or not. If the viewport is not set, change the viewport setting of the HTML content just now into annotation: Firefox on mobile phone displays as follows: Enlarge the reduced part and you will see: Since the default viewport width is 980, in order to fully display the horizontal content of the web page, it is automatically reduced to 0.4224 times in order to display the horizontal content of the web page. This multiple is larger than the default value of minimum-scale of 0.1, and will replace the minimum-scale setting. Even if the user reduces the display by himself, he can only reduce the display to 0.4224 times at most. If you add the viewport settings back: The screen you see will be like this: You can see that the width of the viewport (window.innerWidth) and the width of the device screen (window.screen.width) are the same, both are 414px. The webpage will be displayed with this width, and the zoom factor is 1. OK Clearly read the displayed web page content. Since this is the maximum zoom factor that can display horizontal content on a web page, it will also replace the default minimum-scale of 0.1. Users can only zoom the page to a minimum of 1 times. If you keep the default zoom factor of 1, but don’t set the viewport width, like this: The actual result is the same as setting the width to device-width. If you deliberately set the viewport width to 980: will be displayed as follows: Since the width of the viewport is now wider than the screen, it will extend outside the screen during arrangement. You can also see from the actual displayed results that the screen width is indeed 980. If you deliberately set the viewport width to be narrower than the screen, like: The browser will use the screen width as the lowest viewport width, so the display result will be the same as setting the width to device-width: If you only set the viewport width, but not the initial-scale, like this: Still using 1.0 as the starting zoom factor. If you change the zoom factor, you can use the specified zoom factor after the web page is first loaded, for example: You will see the result magnified 3 times: Please note that initial-scale is only valid for the first time the web page is loaded. Even if you modify the settings and reload the web page, if the original zoom factor of the web page is within the newly set zoom range, the original zoom factor will be maintained. Therefore, it is recommended to open a new privacy page to test more accurately, otherwise it may happen that modifying the initial-scale does not change the display ratio. If you just want to force users to view the webpage at a magnification level, you can set minimum-scale, but this should be more correct if the webpage content is enlarged from the beginning. Initial-scale can also be set to less than 1, that is, the display is reduced. However, if the viewport width is proportionally reduced to be smaller than the screen width, it will violate the rule that the browser can only be reduced to a minimum size that can display the complete horizontal content of the web page. It will automatically divide the currently set viewport width by the reduction factor, so that the web page can maintain complete horizontal content when it is reduced to the minimum multiple. For example, if set to 0.5: will change the width of the viewport to 414/0.5=828px: Zoom in to see detailed data: If you initially set the viewport width to be wide enough, the setting in the meta tag will be maintained, for example: The results are as follows: You can see the width remains unchanged: If you put an image in a web page, the resolution of the image will be interpreted in px units, so a 200×200 image will be 400×400 on a device with devicePixelRatio of 2 Physical pixels are displayed. For example, we added a picture at the end of the web page just now: This is a 584×604 size image: The web page displays the results as follows: You will see that because the image is wider, it exceeds the screen boundary, but the overall page is still arranged according to the width set by the viewport, so box No. 4 is squeezed into the second column. In this case, the factor that the user can reduce can be smaller than the 1.0 set by initial-scale, and can be as small as the width of the image that can be fully displayed, like this: In the picture above, it has been reduced to 0.749 times. If you deliberately set the viewport width to be the same width as the image: You can see that the results are different from the previous result. Now the two squares 4 and 5 above are ranked in the first column. This is because the viewport setting has become wider. The above is the detailed content of Viewport setting in HTML meta tag. For more information, please follow other related articles on the PHP Chinese website! Undress images for free AI-powered app for creating realistic nude photos Online AI tool for removing clothes from photos. AI clothes remover Swap faces in any video effortlessly with our completely free AI face swap tool! Easy-to-use and free code editor Chinese version, very easy to use Powerful PHP integrated development environment Visual web development tools God-level code editing software (SublimeText3) There are three ways to create a CSS loading rotator: 1. Use the basic rotator of borders to achieve simple animation through HTML and CSS; 2. Use a custom rotator of multiple points to achieve the jump effect through different delay times; 3. Add a rotator in the button and switch classes through JavaScript to display the loading status. Each approach emphasizes the importance of design details such as color, size, accessibility and performance optimization to enhance the user experience. To deal with CSS browser compatibility and prefix issues, you need to understand the differences in browser support and use vendor prefixes reasonably. 1. Understand common problems such as Flexbox and Grid support, position:sticky invalid, and animation performance is different; 2. Check CanIuse confirmation feature support status; 3. Correctly use -webkit-, -moz-, -ms-, -o- and other manufacturer prefixes; 4. It is recommended to use Autoprefixer to automatically add prefixes; 5. Install PostCSS and configure browserslist to specify the target browser; 6. Automatically handle compatibility during construction; 7. Modernizr detection features can be used for old projects; 8. No need to pursue consistency of all browsers, Use the clip-path attribute of CSS to crop elements into custom shapes, such as triangles, circular notches, polygons, etc., without relying on pictures or SVGs. Its advantages include: 1. Supports a variety of basic shapes such as circle, ellipse, polygon, etc.; 2. Responsive adjustment and adaptable to mobile terminals; 3. Easy to animation, and can be combined with hover or JavaScript to achieve dynamic effects; 4. It does not affect the layout flow, and only crops the display area. Common usages are such as circular clip-path:circle (50pxatcenter) and triangle clip-path:polygon (50%0%, 100 0%, 0 0%). Notice Themaindifferencesbetweendisplay:inline,block,andinline-blockinHTML/CSSarelayoutbehavior,spaceusage,andstylingcontrol.1.Inlineelementsflowwithtext,don’tstartonnewlines,ignorewidth/height,andonlyapplyhorizontalpadding/margins—idealforinlinetextstyling Setting the style of links you have visited can improve the user experience, especially in content-intensive websites to help users navigate better. 1. Use CSS's: visited pseudo-class to define the style of the visited link, such as color changes; 2. Note that the browser only allows modification of some attributes due to privacy restrictions; 3. The color selection should be coordinated with the overall style to avoid abruptness; 4. The mobile terminal may not display this effect, and it is recommended to combine it with other visual prompts such as icon auxiliary logos. TheCSSPaintingAPIenablesdynamicimagegenerationinCSSusingJavaScript.1.DeveloperscreateaPaintWorkletclasswithapaint()method.2.TheyregisteritviaregisterPaint().3.ThecustompaintfunctionisthenusedinCSSpropertieslikebackground-image.Thisallowsfordynamicvis To create responsive images using CSS, it can be mainly achieved through the following methods: 1. Use max-width:100% and height:auto to allow the image to adapt to the container width while maintaining the proportion; 2. Use HTML's srcset and sizes attributes to intelligently load the image sources adapted to different screens; 3. Use object-fit and object-position to control image cropping and focus display. Together, these methods ensure that the images are presented clearly and beautifully on different devices. Different browsers have differences in CSS parsing, resulting in inconsistent display effects, mainly including the default style difference, box model calculation method, Flexbox and Grid layout support level, and inconsistent behavior of certain CSS attributes. 1. The default style processing is inconsistent. The solution is to use CSSReset or Normalize.css to unify the initial style; 2. The box model calculation method of the old version of IE is different. It is recommended to use box-sizing:border-box in a unified manner; 3. Flexbox and Grid perform differently in edge cases or in old versions. More tests and use Autoprefixer; 4. Some CSS attribute behaviors are inconsistent. CanIuse must be consulted and downgraded.\n \n \n Firefox on mobile\n<\/h3>\n\n
\n<\/p>\n\n \n<\/pre>\n\n\n\n
<\/p>\n\n
<\/p>\n\n
\n \n \n Set the viewport to be the same width as the screen\n<\/h4>\n\n
\n<\/p>\n\n \n<\/pre>\n\n\n\n
<\/p>\n\n
\n<\/p>\n\n \n<\/pre>\n\n\n\n
\n \n \n Deliberately set the viewport width\n<\/h4>\n\n
\n<\/p>\n\n \n<\/pre>\n\n\n\n
<\/p>\n\n
\n<\/p>\n\n<\/pre>\n\n\n\n
<\/p>\n\n
\n<\/p>\n\n\n\n \n \n
<script>
window.addEventListener('load', function() {
document.getElementById('devicePixelRatio').textContent = window.devicePixelRatio;
document.getElementById('screenWidth').textContent = window.screen.width;
document.getElementById('innerWidth').textContent = window.innerWidth;
// 取得並顯示目前的縮放倍數(shù)
function updateScale() {
const currentScale = window.visualViewport ? window.visualViewport.scale : '不支援';
document.getElementById('currentScale').textContent = currentScale;
}
// 初始化顯示
updateScale();
// 監(jiān)聽(tīng)縮放變化
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', updateScale);
}
});
</script>
1
2
3
4
5
6
7
8
Firefox on mobile
<meta name="viewport" content="width=1200, initial-scale="1.0">
Set the viewport to be the same width as the screen
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Deliberately set the viewport width
<meta name="viewport" content="initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
window.addEventListener('load', function() {
document.getElementById('devicePixelRatio').textContent = window.devicePixelRatio;
document.getElementById('screenWidth').textContent = window.screen.width;
document.getElementById('innerWidth').textContent = window.innerWidth;
// 取得並顯示目前的縮放倍數(shù)
function updateScale() {
const currentScale = window.visualViewport ? window.visualViewport.scale : '不支援';
document.getElementById('currentScale').textContent = currentScale;
}
// 初始化顯示
updateScale();
// 監(jiān)聽(tīng)縮放變化
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', updateScale);
}
});
</script>
1
2
3
4
5
6
7
8
Set a starting multiple greater than 1
<meta name="viewport" content="width=1200, initial-scale="1.0">
Set a starting multiple less than 1
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Display of pictures
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Hot AI Tools
Undress AI Tool
Undresser.AI Undress
AI Clothes Remover
Clothoff.io
Video Face Swap
Hot Article
Hot Tools
Notepad++7.3.1
SublimeText3 Chinese version
Zend Studio 13.0.1
Dreamweaver CS6
SublimeText3 Mac version
Hot Topics
CSS tutorial for creating loading spinners and animations
Jul 07, 2025 am 12:07 AM
Addressing CSS Browser Compatibility issues and prefixes
Jul 07, 2025 am 01:44 AM
Creating custom shapes with css clip-path
Jul 09, 2025 am 01:29 AM
What is the difference between display: inline, display: block, and display: inline-block?
Jul 11, 2025 am 03:25 AM
Styling visited links differently with CSS
Jul 11, 2025 am 03:26 AM
What is the CSS Painting API?
Jul 04, 2025 am 02:16 AM
How to create responsive images using CSS?
Jul 15, 2025 am 01:10 AM
What are common CSS browser inconsistencies?
Jul 26, 2025 am 07:04 AM