DOM element Full Screen Display solution (cont.)

Source: Internet
Author: User

The implementation element full-screen scheme in the previous article only fits into a single element (the element contains no other elements), but what if there are other elements? Like buttons or something like that. Such as:


Add-webkit-full-screen{width:100%; height:100%;} then the full-screen display becomes:

The 1,button uses left and top to locate the image. If you use bottom and right to locate the image


We will find that the element size is as large as screen in fullscreen mode, but the element size and position settings are still original, which is why the above situation occurs.

So what do we do to make sure that the parent element is full-screen and that its child elements remain synchronized relative to the parent element in size and position? In fact, we can use the Zoom property in CSS, that is, the parent element directly to the scale operation. This makes the child elements zoom out together. For example:

var rateheight = parsefloat (screen.height)/$ ("#div"). Height (), var ratewidth = parsefloat (screen.width)/$ ("#div"). Width (); $ ("#div"). CSS ("Zoom", Ratewidth > Rateheight rateheight:ratewidth);

By calculating the dimensions of the element and screen to determine the value of zoom, and to ensure that the element is not variant in full-screen mode, there may be black edges (if the ratio of the element wh is different from the Sreeen WH ratio, the screen is only guaranteed to fill in one direction) and then copied to zoom. In order to simplify the operation jquery is used here. The results are as follows:


OK, so that you can basically meet the requirements, if there are other questions please contact me, front end Technical Exchange Group: 139761568



DOM element Full Screen Display solution (cont.)

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.