CSS Full Screen background image

Source: Internet
Author: User

Spit Groove: Yeah Tomorrow is the National day! Haha, in advance bless you all Park Friends National Day happy, holiday happy, life happy, happy every day! National day I want to go home a trip, put some unused things to take home, visit friends and family, a few days at home soy sauce ~ ~ ~

To get to the point, let's go back to our theme to see the full screen background of CSS. nowdays, full screen large map of the page became a kind of fashion, Web templates, Layout is CSS, HTML ... To design, here is the CSS to talk about the full spelling of the background map.

Simple point, for the full screen background, we just need to use a CSS background-size property on it.

Whenthe value of background-size is cover, the browser automatically scales the width and height of the background graph until it is greater than or equal to viewport width and height.

Body {/* Load background map */background-image:url (http://images.cnblogs.com/cnblogs_com/caidupingblogs/828701/o_5_11911_8.jpg )////background graph vertical, horizontal center */background-position:center center;/* background plot */background-repeat:no-repeat;/* when the content height is greater than the height of the picture, The position of the background image is relative to the viewport fixed */background-attachment:fixed;/* lets the background map set the background color based on the container size scaling */background-size:cover;/* Background color is displayed during the loading of the */background-color: #FF0000;}

One thing to note here is that if the background map is smaller than body the size of the label (for example, on a high-resolution monitor or when the page content is particularly large), the browser stretches the picture. As we all know, when a picture is stretched, the picture becomes blurred.

Therefore, when choosing a background map, pay special attention to dimensions.

Another problem is to view on other media devices, viewing on different screens is not the same, so we want to set max-width:600px as a breakpoint, that is, when the browser viewport greater than 600px, will use a large background map, conversely, the use of small background map. Here is the media Query method:

@media only screen and (max-width:600px) {  body {    Background-image:url (http://images.cnblogs.com/cnblogs_com /caidupingblogs/828701/o_5_11911_8.jpg);}}

CSS Full Screen background image

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.