Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS module landing page #23898

Merged
merged 36 commits into from
Feb 1, 2023
Merged
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f55fccb
Test: let me know what you think
estelle Jan 26, 2023
689d0cb
glossary
estelle Jan 26, 2023
ce1365e
animation
estelle Jan 27, 2023
6281187
animation
estelle Jan 27, 2023
233c738
animation
estelle Jan 27, 2023
6a51071
tweaks
estelle Jan 27, 2023
199bb14
tweaks
estelle Jan 27, 2023
57cb928
animation example
estelle Jan 27, 2023
d60ef1a
prefers reduced motion
estelle Jan 27, 2023
cd36a8a
ground cover
estelle Jan 27, 2023
dab1526
details
estelle Jan 27, 2023
2e84504
details
estelle Jan 27, 2023
5beee71
change associated to related
estelle Jan 27, 2023
4ebd970
tweaks
estelle Jan 27, 2023
98913a5
make example keyboard stoppable
estelle Jan 27, 2023
d95f4bb
tweaks
estelle Jan 28, 2023
d3dfdd1
tests for discussions
estelle Jan 30, 2023
efeb0dc
tests for discussions
estelle Jan 30, 2023
9bb88de
tests for discussions
estelle Jan 30, 2023
38dd438
tests for discussions
estelle Jan 30, 2023
57420b3
updated to Animation example to explain the code
estelle Jan 30, 2023
8c0a670
updated to Animation example to explain the code
estelle Jan 30, 2023
51e9591
make C&B match the template
estelle Jan 30, 2023
7070256
updated to C&B example to explain the code
estelle Jan 31, 2023
a065682
updated to C&B: define filter in see also section
estelle Jan 31, 2023
89f98f9
link to blob
estelle Jan 31, 2023
9670b09
Apply suggestions from code review
estelle Jan 31, 2023
9376a0a
Update index.md
estelle Jan 31, 2023
f7440d9
add experimental
estelle Jan 31, 2023
54ed767
Update files/en-us/web/css/compositing_and_blending/index.md
estelle Jan 31, 2023
e23117b
missing property, experimental inline on other
estelle Jan 31, 2023
40c98ae
testing spaces
estelle Jan 31, 2023
57f6b89
spacing
estelle Jan 31, 2023
ece7d6d
spacing
estelle Jan 31, 2023
e2561e3
remove extra character
dipikabh Feb 1, 2023
b37f4c1
add black line before heading
dipikabh Feb 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 82 additions & 7 deletions files/en-us/web/css/compositing_and_blending/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,76 @@ tags:
- Guide
- Overview
- Reference
browser-compat:
- css.properties.background-blend-mode
- css.properties.isolation
- css.properties.mix-blend-mode
spec-urls:
- https://drafts.fxtf.org/compositing/
- https://www.w3.org/TR/compositing-1/
---

{{CSSRef}}

**Compositing and Blending** is a CSS module that defines how shapes of different elements are combined into a single image.
The **Compositing and Blending** CSS module defines how an element's background layers can be blended together, how an element can be blended with its container, and whether the element must create a new [stacking context](/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).

Similar to blending effects available in many image editing applications, this module enables blending an element's background layers together and blending an element's content with that of its container. CSS can be used to define which blending mode should be used, if any, to blend an element's background images and colors into a single background image. It is also possible to define how an element's borders, background, and content, including text, emojis, and images, should be blended with the background of its container.

This module provides for 16 different blending modes.

### Example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be H2? And why not show source for the example? And might we want to have more than one, and then call it Examples?

I would have the example after the Reference and Associated content, as we usually do for docs (interactive examples aside).

Copy link
Member Author

@estelle estelle Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually didn't want to have a header at all, but didn't know how to show EmbedLiveSample without a header ID. I want to keep the code hidden as this is supposed to be a very brief overview of "why" you would want to dig into the module, not an explanation of what the properties are or how they work. The example is part of the description, not an explanation, which is why it is with the description of the module.

The example also uses a lot of properties and values that are irrelevant to the module, such as borders, grid, backgrounds, gradients. Hiding the code enables including a complex example that shows the power of the whole module without worrying that the reader will get stuck on the details.


In this example, a border and two striped background images with a background color are provided for each box, with a background of a solid color with circles cut out set on the entire example.
estelle marked this conversation as resolved.
Show resolved Hide resolved

```html hidden
<section>
<div><span>Normal, with no blending</span></div>
<div><span>Multiplies colors</span></div>
<div><span>Multiplies based on background color</span></div>
<div>Normal, with no blending</div>
<div>Multiplies colors</div>
<div>Multiplies based on background color</div>
</section>
```

```css hidden
div {
width: 200px;
height: 200px;
background-image: repeating-linear-gradient(45deg, red 0 15px, pink 15px 30px), repeating-linear-gradient(-45deg, blue 0 15px, lightblue 15px 30px);
background-size: 150px 150px;
background-repeat: no-repeat;
background-position: top left, bottom right;
background-color: palegoldenrod;
text-align: center;
padding-top: 150px;
font-family: sans-serif;
box-sizing: border-box;
border: 5px solid black;
}
div:nth-of-type(3n+1){
background-blend-mode: normal;
}
div:nth-of-type(3n+2){
background-blend-mode: multiply;
}
div:nth-of-type(3n+3){
background-blend-mode: overlay;
}
div:nth-of-type(n + 4) {
mix-blend-mode: difference;
}
section {
padding: 0.75em;
background: radial-gradient(circle, transparent 0 20px, rgb(255, 200, 200) 20px); background-size: 60px 60px; background-position: center;
display: inline-grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 1em;
}
span {
background-color: #ffffff99;
}
```

{{ EmbedLiveSample('Example', "630", "300") }}

The last three boxes are set to blend with the background of the container. Note how the background, border, and the content are all impacted.

## Reference

Expand All @@ -30,10 +91,24 @@ browser-compat:

- {{cssxref("&lt;blend-mode&gt;")}}

## Associated content

### Associated properties

- {{cssxref("background-image")}}
- {{cssxref("background-color")}}

### Associated concepts and glossary terms

- Glossary: {{glossary("stacking context")}}
- SVG's {{ SVGElement("feBlend") }} filter primitive

## Specifications

{{Specifications}}

## Browser compatibility
## See also

{{Compat}}
- [Compositing And Blending In CSS](https://www.sarasoueidan.com/blog/compositing-and-blending-in-css/) (2015)
- [Editing Images in CSS: Blend Modes](https://code.tutsplus.com/tutorials/editing-images-in-css-blend-modes--cms-26058) (2022)
- [web.dev: blend modes](https://web.dev/learn/css/blend-modes/) (2021)