Toying with ideas from CSS-Tricks - https://css-tricks.com/how-to-do-knockout-text/ Only works in webkit and recent IE. Firefox would need workaround.
A Pen by Kev Durber on CodePen.
<div class="wrap"> | |
<div class="clip-text clip-text_one">in the jungle, the mighty jungle, the lion sleeps tonight.</div> | |
</div> |
Toying with ideas from CSS-Tricks - https://css-tricks.com/how-to-do-knockout-text/ Only works in webkit and recent IE. Firefox would need workaround.
A Pen by Kev Durber on CodePen.
var tl = new TimelineMax({repeat:-1, yoyo:true}); | |
tl.to(".clip-text", 4, { css:{"background-position": "800px"} , ease:Quad.easeInOut }); |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.16.1/TweenMax.min.js"></script> |
@import url(http://fonts.googleapis.com/css?family=Oswald:400,700); | |
body { | |
font-family: 'Oswald', sans-serif; | |
color: #000; | |
background-color: #fff; | |
} | |
.wrap { | |
max-width: 50%; | |
margin: 0 auto; | |
} | |
/* Clip text element */ | |
.clip-text { | |
font-size: 6em; | |
font-weight: bold; | |
line-height: 1; | |
position: relative; | |
display: inline-block; | |
margin: .25em; | |
padding: .5em .75em; | |
text-align: center; | |
/* Color fallback */ | |
color: #000; | |
-webkit-background-clip: text; | |
-webkit-text-fill-color: transparent; | |
background-clip: text; | |
text-fill-color: transparent; | |
} | |
.clip-text:before, | |
.clip-text:after { | |
position: absolute; | |
content: ''; | |
} | |
/* Background */ | |
.clip-text:before { | |
z-index: -2; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
background-image: inherit; | |
} | |
/* Text outer background */ | |
.clip-text:after { | |
position: absolute; | |
z-index: -1; | |
top: 0em; | |
right: 0em; | |
bottom: 0em; | |
left: 0em; | |
background-color: #fff; | |
} | |
.clip-text_one { | |
background-image: url(http://i.imgur.com/pJewmf8.jpg); | |
} |