我想知道是否有人可以帮助我/如果这是可能的。字体太棒了半风格CSS
我想一半的风格(使用halfstyle.js)在YouTube字体真棒图标,该图标是像YouTube标志(下半部分红色,上半白)
我想在悬停时进行此操作,但我似乎甚至无法像默认那样进行此操作。
body {
background: rgba(0,0,0,.4);
}
.fa {
font-size: 10em;
color: white;
}
.fa-youtube {}
.halfStyle {
position:relative;
display:inline-block;
font-size:80px; /* or any font size will work */
color: transparent; /* hide the base character */
overflow:hidden;
white-space: pre; /* to preserve the spaces from collapsing */
}
.halfStyle:before { /* creates the top part */
display:block;
z-index:2;
position:absolute;
top:0;
height: 50%;
content: attr(data-content); /* dynamic content for the pseudo element */
overflow:hidden;
pointer-events: none; /* so the base char is selectable by mouse */
color: #f00; /* for demo purposes */
text-shadow: 2px -2px 0px #af0; /* for demo purposes */
}
.halfStyle:after { /* creates the bottom part */
display:block;
position:absolute;
z-index:1;
top:0;
height: 100%;
content: attr(data-content); /* dynamic content for the pseudo element */
overflow:hidden;
pointer-events: none; /* so the base char is selectable by mouse */
color: #000; /* for demo purposes */
text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}
<i class="fa fa-youtube textToHalfStyle"></i>
寻找类似[**这**](https://jsfiddle.net/vivekkupadhyay/ogxwpdmd/3)? – vivekkupadhyay
@vivekkupadhyay不,我只是在寻找'管箱'去红色和其余保持不变 – Tom