Css+background achieve picture width and height adaptive, stretch cropping does not deform

Source: Internet
Author: User

Picture width is not fixed, the same realization of self-adaptation, stretching and cutting not deformation, adapt to the major compatibility.

Let's look at two different photos on the Internet:

No.2

From a wide view of a house, it is difficult to adapt to self-adaptation, but the hateful product manager, can only find their own way

Please take a look at the picture below, it is easy to test on the Big browser and mobile phone.

Let's take a comparison first:

Easy to use and not useful

Here's the code: just put a div on the OK.

<Divstyle= "width:500px;  height:600px;  border:1px solid #000000; Background:url (Http://img.zcool.cn/community/[email protected]_1l_2o_100sh.jpg) no-repeat; Background-size:cover; Background-position:center Center;"    ></Div><Divstyle= "width:500px;  height:600px;  border:1px solid #000000;  Background:url (http://img17.3lian.com/d/file/201703/07/4ceeb6fc3d7956ac7731290a603e0a84.jpg) no-repeat;  Background-size:cover; Background-position:center Center; "></Div>

Css+background achieve picture width and height adaptive, stretch cropping does not deform

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.