Thuộc tính chế độ trộn CSS
Ví dụ
Vùng chứa có nền màu đỏ và hình ảnh hòa trộn với vùng chứa màu đỏ (làm tối):
.container {
background-color: red;
}
.container img {
mix-blend-mode: darken;
}
Hãy tự mình thử »Thêm ví dụ "Hãy tự mình thử" bên dưới.
Định nghĩa và cách sử dụng
Thuộc tính mix-blend-mode
chỉ định cách nội dung của phần tử sẽ hòa trộn với nền gốc trực tiếp của nó.
Giá trị mặc định: | Bình thường |
---|---|
Thừa hưởng: | KHÔNG |
Hoạt hình: | KHÔNG. Đọc về hoạt hình |
Cú pháp JavaScript: | object .style.mixBlendMode = "làm tối" Hãy thử |
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Property | |||||
---|---|---|---|---|---|
mix-blend-mode | 41.0 | 79.0 | 32.0 | 8.0 | 35.0 |
Cú pháp CSS
mix-blend-mode: normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|difference|exclusion|hue|saturation|color|luminosity;
Giá trị tài sản
Value | Description | Demo |
---|---|---|
normal | This is default. Sets the blending mode to normal | Demo ❯ |
multiply | Sets the blending mode to multiply | Demo ❯ |
screen | Sets the blending mode to screen | Demo ❯ |
overlay | Sets the blending mode to overlay | Demo ❯ |
darken | Sets the blending mode to darken | Demo ❯ |
lighten | Sets the blending mode to lighten | Demo ❯ |
color-dodge | Sets the blending mode to color-dodge | Demo ❯ |
color-burn | Sets the blending mode to color-burn | Demo ❯ |
difference | Sets the blending mode to difference | Demo ❯ |
exclusion | Sets the blending mode to exclusion | Demo ❯ |
hue | Sets the blending mode to hue | Demo ❯ |
saturation | Sets the blending mode to saturation | Demo ❯ |
color | Sets the blending mode to color | Demo ❯ |
luminosity | Sets the blending mode to luminosity | Demo ❯ |
Thêm ví dụ
Ví dụ
Một cuộc biểu tình của tất cả các giá trị:
.normal {mix-blend-mode: normal;}
.multiply {mix-blend-mode: multiply;}
.screen {mix-blend-mode: screen;}
.overlay {mix-blend-mode: overlay;}
.darken {mix-blend-mode: darken;}
.lighten {mix-blend-mode: lighten;}
.color-dodge {mix-blend-mode: color-dodge;}
.color-burn {mix-blend-mode:
color-burn;}
.difference {mix-blend-mode: difference;}
.exclusion
{mix-blend-mode: exclusion;}
.hue {mix-blend-mode: hue;}
.saturation
{mix-blend-mode: saturation;}
.color {mix-blend-mode: color;}
.luminosity {mix-blend-mode: luminosity;}
Hãy tự mình thử »Ví dụ
Sử dụng chế độ hòa trộn để tạo văn bản cắt/loại bỏ đáp ứng:
.image-container {
background-image: url("paris.jpg");
background-size: cover;
position: relative;
height:
300px;
}
.text {
background-color: white;
color: black;
font-size: 10vw;
font-weight: bold;
margin: 0 auto;
padding: 10px;
width: 50%;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
mix-blend-mode: screen;
}
Hãy tự mình thử »Trang liên quan
Tham chiếu CSS: Thuộc tính chế độ hòa trộn nền CSS