How to fill the entire screen with elements in WeChat applets

Source: Internet
Author: User
This article mainly introduces the implementation of full screen height for elements in small programs. For more information, see how to implement full screen height for elements in small programs.

In projects, a container element is often used to fill the screen height and width, and other elements are placed in the container element.

The width is very simple: width: 100%

But the height, we know, is that height: 100% must be given the height of the parent element.

In the past, I used js to get the screen height and assign it to height,

The screen height is window. innerHeight on the webpage;

In a small program, you need to call the wx. getSystemInfo interface and assign values through setData.

But it is obvious that js is used, and the efficiency is definitely not as high as that of css to directly specify the style.

So we use another method:

Set the body in the webpage, html {height: 100% };

Set the body and html to 100%, so that we can use height: 100% in their sub-elements to fill the screen with our container elements.

However, there is no dom object in the applet, but we can see from the debugging tool that it is in the dom tree (I don't know how to call it, that's it, the root node is page, so let's try using page {height: 100%}

Indeed, it is feasible. The height occupies the window of the entire applet.

So I can continue to write my small program happily.

Thank you for reading this article. I hope it will help you. thank you for your support for this site!

For more information about how to use the full screen height of elements in a small program, see The PHP Chinese website!

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.