background-blend-mode
- for blending background images, gradients and background color of elements;mix-blend-mode
- for mixing elements with other elements;isolation
is a less used property that is used with mix-blend-mode to prevent mixing of elements.background-blend-mode
, the property that enjoys the most widespread support, and the possibilities of using it to create attractive backgrounds and photo effects on your website that were once possible only in Photoshop.background
property. Functions such as linear-gradient()
, radial-gradient()
, repeating-linear-gradient()
and repeating-radial-gradient()
have broad support and more strict, standardized syntax in browsers.background
property can allow more than one gradient, displaying them on top of each other, if you list each next one separated by commas. Lea Verou showed impressive patterns that can be created using this technique: from chess boards to bricks and stars.background-blend-mode
property, we can create all new gradients and patterns. .spectrum-background { background: linear-gradient(red, transparent), linear-gradient(to top left, lime, transparent), linear-gradient(to top right, blue, transparent); background-blend-mode: screen; }
background-blend-mode
. .plaid-background { background: repeating-linear-gradient( -45deg, transparent 0, transparent 25%, dodgerblue 0, dodgerblue 50% ), repeating-linear-gradient( 45deg, transparent 0, transparent 25%, tomato 0, tomato 50% ), repeating-linear-gradient( transparent 0, transparent 25%, gold 0, gold 50% ), white; background-blend-mode: multiply; background-size: 100px 100px; }
.circles-background { background: radial-gradient( khaki 40px, transparent 0, transparent 100% ), radial-gradient( skyblue 40px, transparent 0, transparent 100% ), radial-gradient( pink 40px, transparent 0, transparent 100% ), snow; background-blend-mode: multiply; background-size: 100px 100px; background-position: 0 0, 33px 33px, -33px -33px; }
background-image
allows you to set several gradients for an element, the trick is that in the same way we can set several background images using the url()
construct. When we combine this with background-blend-mode
and properties like filter
, something really interesting can turn out.body
, section
, figure
, we first use the following HTML: <div class=”pencil-effect”></div>
chapel.jpg
with the url of the image you are using. We will set the background image twice and save its background size. .pencil-effect { background: url(chapel.jpg), url(chapel.jpg); background-size: cover; }
background-blend-mode: difference;
background-position
and calc()
. background-position: calc(50% — 1px) calc(50% — 1px), calc(50% + 1px) calc(50% + 1px);
filter
property to invert the photo and translate it into shades of gray. filter: brightness(3) invert(1) grayscale(1);
.pencil-effect { background: url(photo.jpg), url(photo.jpg); background-size: cover; background-blend-mode: difference; background-position: calc(50% — 1px) calc(50% — 1px), calc(50% + 1px) calc(50% + 1px); filter: brightness(3) invert(1) grayscale(1); }
invert(1)
function in the final stage.overlay
mode. This blend mode brightens and darkens the background, and works as a combination of two other blend modes — multiply
and screen
. background: url(moose.jpg); background-size: cover; background-position: center;
background: url(moose.jpg), radial-gradient( rgba(0,255,0,.8), black ); background-blend-mode: overlay;
background: url(moose.jpg), radial-gradient( rgba(0,255,0,.8), black ), repeating-linear-gradient( transparent 0, rgba(0,0,0,.2) 3px, transparent 6px );
.night-vision-effect { background: url(moose.jpg), radial-gradient( rgba(0,255,0,.8), black ), repeating-linear-gradient( transparent 0, rgba(0,0,0,.2) 3px, transparent 6px ); background-blend-mode: overlay; background-size: cover; }
background-blend-mode
property is fully supported in Firefox, Chrome and Opera.saturation
, hue
, color
and luminosity
.background-blend-mode
. The remarkable @supports
CSS @supports
makes it quite simple. Here are two examples.background-blend-mode
function is not supported. We use for our example background: gray
as a reserve, but in this place you can use any CSS. .spectrum-background { background: gray; @supports (background-blend-mode: screen) { background: linear-gradient(red, transparent), linear-gradient(to top left, lime, transparent), linear-gradient(to top right, blue, transparent); background-blend-mode: screen; } }
filter
and background-blend-mode
. If the user's browser does not support them (or if the browser does not support CSS @supports
), we will return to the original photo. .pencil-effect { background-image: url(photo.jpg); background-size: cover; @supports (background-blend-mode: difference) and (filter: invert(1)) { background-image: url(photo.jpg), url(photo.jpg); background-blend-mode: difference; background-position: calc(50% — 1px) calc(50% — 1px), calc(50% + 1px) calc(50% + 1px); filter: brightness(3) invert(1) grayscale(1); } }
LOOKING.HOUSE - the project collected more than 150 points looking glass in 40 countries. You can quickly execute the host, ping, traceroute, and mtr commands.
Source: https://habr.com/ru/post/423115/
All Articles