The difference between "CSS3" Background-origin and Background-clip

Source: Internet
Author: User

Background-clip and Background-origin are the two attributes associated with the element background introduced in CSS3, which have the same optional values, namely border, padding, content three, And both of these properties represent some kind of relationship between the element background and the element border, the padding (padding), and the content area.

Although the two seem to achieve similar results, the two principles are different. Background-origin defines the starting point of the background position (background-position), while Background-clip is the cutting of the background (picture and background color).

1.background-origin

Let's take a look at the example:

Let's take a look at style styles:

. bg{width:100px;            height:100px;            padding:50px; border:10px Dashed #000000; Background: #ffff00 URL (' Pic1.gif ') no-repeat; Margin-top:10px; Display:inline-Block; }. bg_origin_border{Background-origin:border-box; /*background-position:10px 10px;*/}. bg_origin_padding{background-origin:padding-box; /*background-position:10px 10px;*/}. bg_origin_content{background-origin:content-box; /*background-position:10px 10px;*/        }

Here we open the note to further verify the Backgroung-origin.

2.backgroung-clip

Let's take a look at the example:

Style:

. bg_clip_border{            background-clip:border-box;             /* background-position: -10px-10px; */         }        . bg_clip_content{            background-clip:content-box;             /* background-position: -10px-10px; */         }        . bg_clip_padding{            background-clip:padding-box;             /* background-position: -10px-10px; */         }

We then remove the comment:

  This confirms that the background-clip is just a rough cut of the background and back color.

The difference between "CSS3" Background-origin and Background-clip

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.