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!