Animation of the opacity of each letter from left to right:
You can animate each opacity of letters by combining svg linearGradient and mask and using JavaScript to switch the x1 and x2 attributes of the linearGradient events to mouseover and mouseleave .
var grad = document.getElementById('gradient');
<svg> <defs> <linearGradient id="gradient" x1="-15%" y1="0%" x2="0%" y2="0%"> <stop stop-color="white" offset="0" /> <stop stop-color="black" offset="1" /> </linearGradient> <mask id="mask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox"> <rect width="1" height="1" fill="url(#gradient)" /> </mask> </defs> <foreignObject width="90px" height="100%" x="2" y="12" mask="url(#mask)"> <div class="two">This is a label</div> </foreignObject> </svg>
Slide from left to right:
You can transition property of transform .
Updated Fiddle
.two { display: block; width: 300px; padding: 15px; } .two:before { content: "T"; } .two:hover:before { display: none; } .two:after { position: absolute; content: "This is a Label"; transform: translateX(-150%); transition: transform 1s ease; } .two:hover:after { content: "This is a Label"; transform: translateX(0%); }
<div class="two"></div>
chipChocolate.py
source share