CSS自适应布局的一些问题
不能设置字体的单位为 vw, 否则用户没法用 zoom(放大缩小页面)功能了
h1 { font-size: 6vw; }
The problem with doing the above is that the user loses the ability to zoom any text set using the vw unit, as that text is always related to the size of the viewport. Therefore you should never set text using viewport units alone.
There is a solution, and it involves using calc(). If you add the vw unit to a value set using a fixed size such as ems or rems then the text will still be zoomable. Essentially, the vw unit adds on top of that zoomed value:
There is a solution, and it involves using calc(). If you add the vw unit to a value set using a fixed size such as ems or rems then the text will still be zoomable. Essentially, the vw unit adds on top of that zoomed value:
h1 { font-size: calc(1.5rem + 3vw); }
手机操作系统给出的屏幕的viewport上给的是错的,If you've got a narrow screen layout that kicks in at 480px viewport width or less, and the viewport is set at 960px, you'll never see your narrow screen layout on mobile.
要加上
<meta name="viewport" content="width=device-width,initial-scale=1">
- initial-scale: Sets the initial zoom of the page, which we set to 1.
- height: Sets a specific height for the viewport.
- minimum-scale: Sets the minimum zoom level.
- maximum-scale: Sets the maximum zoom level.
- user-scalable: Prevents zooming if set to no.
You should avoid using minimum-scale, maximum-scale, and in particular setting user-scalable to no. Users should be allowed to zoom as much or as little as they need to; preventing this causes accessibility problems.
阅读量: 542
发布于:
修改于:
发布于:
修改于: