Fe-interview: [css] 第206天 如果给一个元素设置background-color,它的颜色会填充哪些区域呢?

Created on 7 Nov 2019  ·  1Comment  ·  Source: haizlin/fe-interview

第206天 如果给一个元素设置background-color,它的颜色会填充哪些区域呢?

我也要出题

css

Most helpful comment

background填充区域默认为content、padding和border区域。
然而该行为由background-clip属性决定,默认为border-box

该属性对应的 background 填充对应区域如下:

|background-clip|margin|border|padding|content|text|
|---|---|---|---|---|---|
| border-box (默认)|✘|✔|✔|✔|-|
|padding-box|✘|✘|✔|✔|-|
|content-box|✘|✘|✘|✔|-|
|text (webkit)|✘|✘|✘|✘|✔|

>All comments

background填充区域默认为content、padding和border区域。
然而该行为由background-clip属性决定,默认为border-box

该属性对应的 background 填充对应区域如下:

|background-clip|margin|border|padding|content|text|
|---|---|---|---|---|---|
| border-box (默认)|✘|✔|✔|✔|-|
|padding-box|✘|✘|✔|✔|-|
|content-box|✘|✘|✘|✔|-|
|text (webkit)|✘|✘|✘|✘|✔|

Was this page helpful?
0 / 5 - 0 ratings