赞
踩
"vw" = "view width""vh" = "view height"
使用 CSS3 引入的 vw / vh 基于宽度/高度相对于窗口大小。
- /* 元素根据手机屏幕宽高占位100% */
- .view {
- height: 100vh;
- width: 100vw;
- }
第二种方案
使用微信小程序提供的 API 来获取窗口大小,具体看文档。
onLoad: function () {
this.setData({
height: wx.getSystemInfoSync().windowHeight,
width: wx.getSystemInfoSync().windowWidth
})
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。