Css3-background Clip and background origin

Source: Internet
Author: User

1.background-origin

There are 3 parameters in Background-origin: Border-box | Padding-box | Content-box;

Border-box,padding-box,content-box from the border, or the padding (the default), or the content area to start displaying.

Code Demo:

<! DOCTYPE html>"Utf-8"> <title> background </title> <style type="Text/css">. Wrap {width:220px;            border:10px dashed salmon;            padding:20px; Font-Weight:bold; color:# the; Background: #ccc URL (4. png) no-repeat; Background-origin:border-box;        position:relative;            }. content {height:80px; border:1px Solid #333; }    </style>class="Wrap"> <divclass="content">content</div></div></body>

The inserted picture is placed locally:

Effect

(1) Padding-box

(2) Content-box

(3) Border-box

2.background Cllip

Used to tailor the background image to fit the actual needs.

Grammar:

Background-clip:border-box | Padding-box | Content-box | No-clip

Code Demo:
 <! DOCTYPE html> " utf-8  "  > <title> background Origin </title> <style type=< Span style= "COLOR: #800000" > " text/css  "             > wrap {width:220px;            border:10px dashed salmon;            padding:20px;            Font -weight:bold;            color:#  000  ;            Background: #ccc URL ( 4 . png) No-repeat; Background -clip:border-box;/* Change the value of background,  Border-box | Padding-box | Content-box | No-clip */
position:relative;} . content {height:80px; border:1px solid #333class="wrap"  Class="content">content</div> </div> </body> < /html>

Effect
(1) Border-box

The picture does not start from the left border


(2) Padding-box

(3) Content-box

(4) The difference between backround clip and background origin

The real role of Background-clip is to determine which areas the background is displayed in.

Background-origin refers to the area where the background is displayed, or where the background is drawn from (border, filter, or content area)

Background origin

(1) Padding-box

(2) Content-box

(3) Border-box

Background clip

(1) Border-box


The picture does not start from the left border
(2) Padding-box


(3) Content-box

As can be seen from the 6 above, the picture of background origin is from the border, the padding, the content begins, The background color does not change, The picture of background clip is displayed in the border, padding, content, background color change, background color from border, inner margin, content started, no place blank

PS: Watch for changes in background color


Css3-background Clip and background origin

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.