Use the CSS3 telescopic box to vertically center images, while the css3 telescopic vertical center

Source: Internet
Author: User

Use the CSS3 telescopic box to vertically center images, while the css3 telescopic vertical center

There are many ways to use CSS to vertically center images. for mobile devices, you can use CSS3 expansion boxes to vertically center images.

The Code is as follows:

<Div class = "box">  </div>
1. box {4 display: flex;/* the container is a telescopic box */5 align-items: center; /* align the vertical axis to center */6} 7 img {8 width: 100%; 9}

The above is the implementation of the new version of the telescopic box, support Android 4.4 +, if you need to be compatible with Android 4.4-, you need to add an additional expansion box, as shown below:

. Box {display:-webkit-box;/* the container is the old expansion box */-webkit-box-align: center;/* set the alignment mode of the old expansion box */display: flex; /* the container is a telescopic box */align-items: center;/* The alignment on the vertical axis is set to center */} img {width: 100% ;}

 

Related Article

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.