Flex to add scroll bar to the page implementation ideas and code _flex

Source: Internet
Author: User
Tags numeric value
Modify index.template.html, add a section of JS to get the width of the browser window, according to the browser window width and height to modify the CSS style, html, body {height:100%; width:100%} Height and width are percentages or specific sizes, scroll bars appear when they are specific sizes and fill the entire window when they are percentages.

Specifically as follows:
1. Add the following JS source code (application size is 1100x600)
Copy Code code as follows:

var winwidth = 0;
var winheight = 0;
function Finddimensions ()
{
Get window width
if (window.innerwidth)
{
Winwidth = window.innerwidth;
}
else if ((document.body) && (document.body.clientWidth)
{
Winwidth = Document.body.clientWidth; Get window Height
}
if (window.innerheight)
{
Winheight = Window.innerheight;
}
else if ((document.body) && (document.body.clientHeight)
{
Winheight = Document.body.clientHeight;
}
Get the window size by detecting the body inside the document
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 () {
Call function, get numeric value
Finddimensions ();

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.