Home  >  Article  >  Web Front-end  >  手机浏览器适配_html/css_WEB-ITnose

手机浏览器适配_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:45:411277browse

meta

做手机网页经常会看到这样的一句代码

  • width=device-width 设置视图的宽度等于设备屏幕的宽度
  • initial-scale=1 设置初始缩放比例为1
  • minimum-scale=1 设置最小的缩放比例为1
  • maximum-scale=1 设置最大的缩放比例为1
  • user-scalable=no 不允许缩放
  • 做一个简单粗暴的变换


    将视图的宽度设为320,最大缩放比设为1.3,不设置初始缩放比。
    这样可以将整个视图进行缩放

    rem

    字体单位

  • px 无继承,常用
  • em 继承,相对于父元素继承
  • rem 继承,相对于root继承,一般为html,为css3属性,支持IE9+及其他现代浏览器
  • vh 1vh=视窗高度/100,为css3属性,支持IE9+,chrome20+,firefox19+,safari6+,android browser4.4+
  • vw 1vw=视窗宽度/100

    利用rem

    通过js来计算根元素的font-size,从而适应各种屏幕

    利用vh

    vh本来就是视窗高度的,根据不同的屏幕的视窗高度来适应

  • p.s.果然我还是不会写博客

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn