FLEX:给页面添加滚动条

时间:2022-07-09 17:09:49

修改index.template.html,加入一段js获取浏览器窗口的宽高,根据浏览器窗口宽高修改css样式,html, body { height:100%; width:100%;  }的height和width是百分比还是具体大小,当是具体大小时就会出现滚动条,当是百分比时就会充满整个窗口。

具体如下:
1.加入以下js原码(Application大小为1100X600)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 var
winWidth = 0;
 var
winHeight = 0;
 function
findDimensions()
 {  //获取窗口宽度  if
(window.innerWidth)
  {   winWidth = window.innerWidth;  }  else
if
((document.body) && (document.body.clientWidth))
  {   winWidth = document.body.clientWidth; //获取窗口高度  }  if
(window.innerHeight)
  {   winHeight = window.innerHeight;  }  else
if
((document.body) && (document.body.clientHeight))
  {   winHeight = document.body.clientHeight;  }  //通过深入Document内部对body进行检测,获取窗口大小  if
(document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth)
  {  winHeight = document.documentElement.clientHeight;  winWidth = document.documentElement.clientWidth;     var
cssSize = document.styleSheets[0].rules||document.styleSheets[0].cssRules;
  if(winWidth < 1100)  {  cssSize[0].style.width = "1100px";  }  else  {  cssSize[0].style.width = "100%";  }   if(winHeight < 600)  {  cssSize[0].style.height = "600px";  }  else  {  cssSize[0].style.height = "100%";  } }  window.onresize=findDimensions;   function
pageInit() {
    //调用函数,获取数值   findDimensions();
 }
原文: http://www.wbgen.com/blog/flex4%E8%AE%A9%E6%B5%8F%E8%A7%88%E5%99%A8%E7%AA%97%E5%8F%A3%E5%B0%8F%E4%BA%8Eapplication%E5%A4%A7%E5%B0%8F%E6%97%B6%E5%87%BA%E7%8E%B0%E6%BB%9A%E5%8A%A8%E6%9D%A1