html - CSS: Fade-in transition in input text? -
is there way write css transition fade in input text element while user typing?
currently, text can fade in within normal html text element because can tell transition 0 1 opacity; input text doesn't exist before user types in.
so example, if type in username, letters type fade in, each 1 going 0 1 opacity in .3 seconds.
i've tried using transition , animation, want keep within css.
a possible way achieve similar effect: create partially transparent overlay using linear-gradient , gradually reveal type moving mask position.
<div id='container'> <input type='text'></input> <div class='fader'></div> </div> $("input").on("keydown", function(e) { var width = $("input").val().length + 1; $(".fader").css("left", (width * 8) + 3); }); #container { position: relative; height: 25px; width: 400px; } input { width: 100%; } input, .fader { display: block; position: absolute; top: 0; left: 0; right: 0; bottom: 0; font-family: monospace; } .fader { top: 2px; bottom: 4px; pointer-events: none; background: linear-gradient(90deg, transparent 0px, white, 15px, white 100%); transition: left 1s ease; }
here's looks fiddle:
Comments
Post a Comment