javascript - How to achieve this awesome CSS animation -
i'm trying animation using css | css3 , javascript. show in image below, it's difficult me this. please me out in this. here code have.
body { background-color: #222; } .container { background-image: url(test.jpg); height: 96vh; width: 100%; } .box { background-color: #fff; height: 98vh; width: 100%; } .big { font-size: 17vw; background: url(http://viralsweep.com/blog/wp-content/uploads/2015/02/unsplash.jpg) 33px 659px; -webkit-text-fill-color: transparent; -webkit-background-clip: text; padding-top: 24vh; margin-top: 0; text-align: center; animation: opac 2s infinite; } @keyframes opac { 0%, 100% { /*rest move*/ } 50% { /*move distance in y position*/ } }
<div class="container"> <div class="box"> <h1 class="big">try this</h1> </div> <!--end of box--> </div> <!--end of conatiner-->
i came solution based on original code using -webkit-text-fill-color
, -webkit-background-clip-text
, added font-size
, negative text-indent
animation. negative text-indent
needed keep text "centered" within element because text within elements wants bump against left edge.
* { box-sizing: border-box; } html, body { height: 100%; margin: 0; padding: 0; } #container { height: 160px; overflow: hidden; position: absolute; width: 600px; } #image { animation: scale 3000ms linear infinite; background: url(http://viralsweep.com/blog/wp-content/uploads/2015/02/unsplash.jpg); bottom: 0; font: 96px "arial"; font-weight: bold; left: 0; line-height: 160px; overflow: hidden; position: absolute; right: 0; text-align: center; top: 0; text-transform: uppercase; white-space: nowrap; -webkit-text-fill-color: transparent; -webkit-background-clip: text; } @keyframes scale { 0% { font-size: 66px; text-indent: 0; } 16% { font-size: 132px; text-indent: 0; } 80% { font-size: 330px; text-indent: -500px; } 100% { font-size: 10000px; text-indent: -25300px; } }
<div id="container"> <div id="image">try this</div> </div>
basically, i'm adjusting text-indent
font-size increases middle "t" stays centered (it's not in center though) , text becomes big (10,000 pixels!) "t" "reveal" effect filling space.
Comments
Post a Comment