gpt4 book ai didi

html - CSS从混合混合模式差异中分离图像

转载 作者:太空宇宙 更新时间:2023-11-04 05:52:04 25 4
gpt4 key购买 nike

我正在使用 mix-blend-mode: difference 在 HTML 上应用暗模式效果。一切正常,除了图像,图像也会受到叠加层的影响。我尝试使用以下方法隔离元素:

img {
isolation: isolate;
}

或在容器内

.img-wrap {
width: 45%;
padding: 1%;
position: relative;
isolation: isolate;
margin: 0 auto;
}

我想要原图。这看起来如何: enter image description here

这是完整的HTML

#blender {
width: 100vw;
height: 100vh;
left: 0pt;
top: 0pt;
position: fixed;
background: white;
transition: all 1s ease;
mix-blend-mode: difference;
pointer-events: none;
}

.img-wrap {
width: 45%;
padding: 1%;
position: relative;
isolation: isolate;
margin: 0 auto;
}

img {
isolation: isolate;
}

.darkmode-background {
position: fixed;
background: white;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
pointer-events: none;
}
<div>
<div style="font-size: 16pt; font-weight: bold"><font face="Comic Sans MS">1. Words marathon</font>
<div></div>
</div>
</div>
<div>
<div class="img-wrap"><img src="https://cdn.pixabay.com/photo/2012/04/13/13/19/clock-32380_960_720.png"></div>
<br>
<div><font face="Comic Sans MS">Ask students to make 5 cards each with any word in English. As a rule, it cannot be a name. If you are revising a certain chapter, the words can be from a category previously stated. Then put all the cards together and devide the students in 2 or 3 teams. One student from the first team comes to the front and picks a card and he/she has to describe it to his team. He/she has to describe as many words/cards as possible in 1 minute. The students from the other teams have to watch the time.&nbsp;</font></div>
<div><font face="Comic Sans MS"><br></font></div>
<div style="font-size: 16pt; font-weight: bold">
<div><font face="Comic Sans MS">2. Bingo</font></div>
<div><font face="Comic Sans MS"><br></font></div>
<div></div>
</div>
<div><font face="Comic Sans MS"><img src="https://image.shutterstock.com/image-photo/bingo-filled-red-pencil-600w-773393032.jpg" alt="Bingo lot is filled in with red pencil"></font></div>
<div><font face="Comic Sans MS">This is just like the traditional game of bingo, but instead of numbers, you have words. Students draw a table on their notebook and the teacher sets the topic. Then students write a word in each box. Teacher starts the game by saying words and students cross them out on their notebook. The student who has all the boxes crossed, shouts BINGO and is the winner. The game continues until all students get to Bingo.&nbsp;</font></div>
<div><font face="Comic Sans MS"><br></font></div>
</div>
<div id="darkmode-container">
<div class="darkmode-background"></div>
<div id="blender"></div>
</div>

如果可能的话,隔离图像的工作片段会很棒。

最佳答案

Isolate 对你不起作用。只需增加图像的 z-index 使其位于图层之上

#blender {
width: 100vw;
height: 100vh;
left: 0pt;
top: 0pt;
position: fixed;
background: white;
transition: all 1s ease;
mix-blend-mode: difference;
pointer-events: none;
}

.img-wrap {
width: 45%;
padding: 1%;
position: relative;
margin: 0 auto;
z-index: 2;
}

img {
position: relative;
z-index: 2;
}

.darkmode-background {
position: fixed;
background: white;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
pointer-events: none;
}
<div>
<div style="font-size: 16pt; font-weight: bold">
<font face="Comic Sans MS">1. Words marathon</font>
<div></div>
</div>
</div>
<div>
<div class="img-wrap"><img src="https://cdn.pixabay.com/photo/2012/04/13/13/19/clock-32380_960_720.png"></div>
<br>
<div>
<font face="Comic Sans MS">Ask students to make 5 cards each with any word in English. As a rule, it cannot be a name. If you are revising a certain chapter, the words can be from a category previously stated. Then put all the cards together and devide the students in 2 or
3 teams. One student from the first team comes to the front and picks a card and he/she has to describe it to his team. He/she has to describe as many words/cards as possible in 1 minute. The students from the other teams have to watch the time.&nbsp;</font>
</div>
<div>
<font face="Comic Sans MS"><br></font>
</div>
<div style="font-size: 16pt; font-weight: bold">
<div>
<font face="Comic Sans MS">2. Bingo</font>
</div>
<div>
<font face="Comic Sans MS"><br></font>
</div>
<div></div>
</div>
<div>
<font face="Comic Sans MS"><img src="https://image.shutterstock.com/image-photo/bingo-filled-red-pencil-600w-773393032.jpg" alt="Bingo lot is filled in with red pencil"></font>
</div>
<div>
<font face="Comic Sans MS">This is just like the traditional game of bingo, but instead of numbers, you have words. Students draw a table on their notebook and the teacher sets the topic. Then students write a word in each box. Teacher starts the game by saying words and students
cross them out on their notebook. The student who has all the boxes crossed, shouts BINGO and is the winner. The game continues until all students get to Bingo.&nbsp;</font>
</div>
<div>
<font face="Comic Sans MS"><br></font>
</div>
</div>
<div id="darkmode-container">
<div class="darkmode-background"></div>
<div id="blender"></div>
</div>

有关 isolation 工作原理的更多详细信息:How to use CSS combination of mix-blend-mode and isolation?

关于html - CSS从混合混合模式差异中分离图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58181754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com