混合混合模式按钮悬停事件问题
Mix Blend Mode button hover event issue
我正在尝试让 mix-blend-mode
正常工作,以便出现背景幻灯片。我整理了 a jsfiddle of it sort of working.
问题是,需要它看起来 more like this。
但我不想消除它的倾斜或从右侧滑入。我已经尝试使用与该示例相同的混合模式,但无论我做什么,它都不会在悬停时保持红色幻灯片颜色,在红色下保持白色文本。我只想使用伪元素,并将 html 保持在最低限度。我认为使用伪元素是可能的,但是混合模式与我不合作并且不确定如何让它看起来更像第二个 fiddle。我的html如下:
<a href="#" class="btn">View Project</a>
CSS 是:
a {
position: relative;
text-decoration: none;
display: inline-block;
padding: 15px 30px;
border: 1px solid #f16251;
background: black;
color: #f16251;
font-size: 30px;
font-family: arial;
mix-blend-mode: normal;
overflow:hidden;
z-index: 1;
}
a:before {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: red;
mix-blend-mode: multiply;
transform-origin:0 0 ;
transform:translateX(100%) skewX(30deg);
transition: transform .25s;
z-index: 3;
}
a:hover:before {
transform: translateX(45%) skewX(30deg);
}
a:hover:after {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
width: 100%;
height: 100%;
background: white;
}
a:after {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: white;
mix-blend-mode: difference;
z-index: 2;
}
如何让背景文本仅在红色滑过文本时显示为白色?我的 mix-blend-mode
代码一定是错误的,但看起来可以在这里做。
嗯,这很有趣 :)
a {
position: relative;
text-decoration: none;
display: inline-block;
padding: 15px 30px;
border: 1px solid #f16251;
background: white;
color: black;
font-size: 30px;
font-family: arial;
mix-blend-mode: normal;
overflow:hidden;
z-index: 1;
}
a:before {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: white;
mix-blend-mode: difference;
transform-origin:0 0 ;
transform:translateX(100%) skewX(30deg);
transition: transform .25s;
z-index: 3;
}
a:hover:before {
transform: translateX(45%) skewX(30deg);
}
a:after{
content: '';
display:block;
top: 0;
left:0;
bottom:0;
right:0;
position: absolute;
z-index: 100;
background: #f16251;
mix-blend-mode: screen;
}
<a href="#" class="btn">View Project</a>
我正在尝试让 mix-blend-mode
正常工作,以便出现背景幻灯片。我整理了 a jsfiddle of it sort of working.
问题是,需要它看起来 more like this。
但我不想消除它的倾斜或从右侧滑入。我已经尝试使用与该示例相同的混合模式,但无论我做什么,它都不会在悬停时保持红色幻灯片颜色,在红色下保持白色文本。我只想使用伪元素,并将 html 保持在最低限度。我认为使用伪元素是可能的,但是混合模式与我不合作并且不确定如何让它看起来更像第二个 fiddle。我的html如下:
<a href="#" class="btn">View Project</a>
CSS 是:
a {
position: relative;
text-decoration: none;
display: inline-block;
padding: 15px 30px;
border: 1px solid #f16251;
background: black;
color: #f16251;
font-size: 30px;
font-family: arial;
mix-blend-mode: normal;
overflow:hidden;
z-index: 1;
}
a:before {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: red;
mix-blend-mode: multiply;
transform-origin:0 0 ;
transform:translateX(100%) skewX(30deg);
transition: transform .25s;
z-index: 3;
}
a:hover:before {
transform: translateX(45%) skewX(30deg);
}
a:hover:after {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
width: 100%;
height: 100%;
background: white;
}
a:after {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: white;
mix-blend-mode: difference;
z-index: 2;
}
如何让背景文本仅在红色滑过文本时显示为白色?我的 mix-blend-mode
代码一定是错误的,但看起来可以在这里做。
嗯,这很有趣 :)
a {
position: relative;
text-decoration: none;
display: inline-block;
padding: 15px 30px;
border: 1px solid #f16251;
background: white;
color: black;
font-size: 30px;
font-family: arial;
mix-blend-mode: normal;
overflow:hidden;
z-index: 1;
}
a:before {
content: '';
position: absolute;
top: 0; bottom: 0; right: 0;
width: 100%; height: 100%;
background: white;
mix-blend-mode: difference;
transform-origin:0 0 ;
transform:translateX(100%) skewX(30deg);
transition: transform .25s;
z-index: 3;
}
a:hover:before {
transform: translateX(45%) skewX(30deg);
}
a:after{
content: '';
display:block;
top: 0;
left:0;
bottom:0;
right:0;
position: absolute;
z-index: 100;
background: #f16251;
mix-blend-mode: screen;
}
<a href="#" class="btn">View Project</a>