How do I use CSS to adapt a picture to the screen?

Source: Internet
Author: User
This article mainly introduces how to realize the effect of CSS image adaptive screen. The simplest method for beginners is to write a picture in the background of a div. This will enable you to adapt to the screen size and not have a horizontal scroll bar.

The CSS Image Adaptive Screen code example is as follows:

Background:url (1.jpg) Center No-repeat;background:url (image address) 0 0 no-repeat Scroll transparent;background-size:100% 100% */* Picture fixed in IMS inside */<div class= "IMS" ></ Div>

Note: Insert the image in HTML, if you want the image to adapt to the screen's small instead of the width and height of the fixed can be added in the CSS code

img {height:auto; width:auto\9; width:100%;}

\9 is a form of hack CSS, which is added "\9" after the normal CSS code, only IE browser can be recognized, other browsers will ignore this statement. In this way, the browser can be differentiated to achieve the purpose of compatible browsers.

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.