A detailed description of the new unit (VW) in CSS3

Source: Internet
Author: User

CSS3 VW units


Paste_image.png

100VW = 100% window width
100VH = 100% Window height

This enables an adaptive square (a container with a fixed length-to-width ratio) to be quite simple!

[Lang=stylus].box  width 10vw  height 10vw

Since it is a new unit, there is bound to be a compatibility issue.

[Lang=jade].img-box  img (src= "Img/a.png")
[Lang=stylus].img-box  width 10vw  height 10vw  img    width 100%    height 100%    object-fit cover


Paste_image.png

The normal effect of the code should be on the left, to implement a square box to put a picture, adaptive centering
However, on Android 4.4, images will be distorted, and the height is not calculated in. Img-box, as shown on the upper right ( object-fit cover not valid on Android 4.4)

Accidental Discovery can position absolute resolve height error problem by setting picture ( object-fit cover Invalid)

[Lang=stylus].img-box  width 10vw  height 10vw  position relative  img    position Absolute left    0    Top 0    width 100%    height 100%    object-fit cover

CSS3 New flex vw vh make layout flexible and convenient many
The square no longer uses padding-bottom 100% the method which lets the person see not easy to understand

Finally, I hope you will use Chrome to get rid of IE soon

"Recommended"

1. Free CSS Online video tutorial

2. CSS Online Manual

3. php.cn Lonely Nine-base (2)-css video tutorial

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.