Viewport
一句话解释
viewport 是可见区域的 web page in 浏览器 window 哪里内容是 displayed.
用大白话说
viewport 是the part of the web page that is currently visible in the browser window。 Everything outside the viewport is scrolled to — it exists in the document but is not currently visible.
On mobile devices, the viewport is more complex because the browser viewport and the device screen size differ. The <meta name="viewport" 内容="宽度=device-宽度, 初始-scale=1"> tag tells the browser to set the viewport width to the device width, which is essential for responsive design on mobile.
CSS viewport units let you size elements relative to the viewport: vw (1% of viewport width), vh (1% of viewport height), vmin (smaller of vw/vh), and vmax (larger). These are useful for full-screen sections and responsive typography.
示例
<meta name="viewport" content="width=device-width, initial-scale=1.0">
/* CSS using viewport units */
.hero { height: 100vh; } /* Full viewport height */
h1 { font-size: 5vw; } /* 5% of viewport width */viewport meta 标签 for responsive mobile 设计, and CSS viewport 单元 for sizing 相对到 viewport.
相关术语
相关资源
相关课程
- CSS Responsive 设计
Viewport and responsive 设计.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。