CSS3中媒体查询结合rem布局适配手机屏幕
程序员文章站
2023-11-11 14:07:22
这篇文章主要介绍了css3中媒体查询结合rem布局适配手机屏幕,需要的朋友可以参考下... 19-06-10...
css3语法: (750px设计图的1rem = 100px)
@media only screen and (min-width: 320px) and (max-width: 479px){ html { font-size: 42.67px !important; } } @media only screen and (min-width: 480px) and (max-width: 639px){ html { font-size: 64px !important; } } @media only screen and (min-width: 640px) and (max-width: 749px){ html { font-size: 85.34px !important; } } @media only screen and (min-width: 750px) and (max-width: 959px){ html { font-size: 100px !important; } } @media only screen and (min-width: 960px) and (max-width: 1241px){ html { font-size: 128px !important; } } @media only screen and (min-width: 1242px){ html { font-size: 165.6px !important; } }
js控制
(zepto / jquery)(750px设计图的1rem = 100px) function setfont() { let window_width = window.innerwidth; let font_size = parsefloat(window_width / 3.75); $('html').css('font-size', font_size); } $(window).on('resize', function () { setfont(); });
总结
以上所述是小编给大家介绍的css3中媒体查询结合rem布局适配手机屏幕,希望对大家有所帮助
上一篇: linux中xargs命令的各种使用技巧
下一篇: Mysql 游标初识