webapp中使用 rem设置对象大小
2016-06-17 15:55
513 查看
<style type="text/css">
.icon {
width: 0.7rem; /* 像素换算rem:140px / 100 = 1.4rem */
height: 0.35rem;
margin: 0 0 0 .5rem;
}
</style>
<script>
(function () {
document.addEventListener('DOMContentLoaded', function () {
var html = document.documentElement;
var windowWidth = html.clientWidth;
html.style.fontSize = windowWidth / 3.2 + 'px';
// 等价于html.style.fontSize = windowWidth /320 * 100 + 'px';
}, false);
})();
// 这个6.4就是根据设计稿的横向宽度来确定的,假如你的设计稿是750
// 那么 html.style.fontSize = windowWidth / 7.5 + 'px';
</script>
.icon {
width: 0.7rem; /* 像素换算rem:140px / 100 = 1.4rem */
height: 0.35rem;
margin: 0 0 0 .5rem;
}
</style>
<script>
(function () {
document.addEventListener('DOMContentLoaded', function () {
var html = document.documentElement;
var windowWidth = html.clientWidth;
html.style.fontSize = windowWidth / 3.2 + 'px';
// 等价于html.style.fontSize = windowWidth /320 * 100 + 'px';
}, false);
})();
// 这个6.4就是根据设计稿的横向宽度来确定的,假如你的设计稿是750
// 那么 html.style.fontSize = windowWidth / 7.5 + 'px';
</script>
相关文章推荐
- Eclipse通过Maven插件创建webapp项目中遇到的问题
- 移动开发(webapp)过程中的小细节总结
- webapp 与sass
- 部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题
- webApp移动开发之REM
- web.xml中webAppRootKey
- SpringMVC 上下文webApplicationContext
- 【web前端】记webApp开发记录
- web.xml中webAppRootKey
- 如此繁荣的移动webapp开发市场:总结当下的一些移动web开发套件
- jetty项目部署与配置
- web.xml中webAppRootKey
- Framework7中文教程-中文演示DEMO
- webapp开发
- WebApp中调试jsavascript
- webkit webApp 开发技术要点总结
- webapp
- HTML5实现webApp中图片轮播的效果(二)之 iSlider 爬坑经历
- springMvc中WebApplicationContext的继承关系
- 服务器启动时Webapp的web.xml中配置的加载顺序