I would like to create an animation that changes the width of the box from 0% 50px to the value entered.
I don't know how to set the input value with the keyframe parameter.
This is HTML.
<dl>
<dt>0%</dt>dd>50px</dd>
<dt>100%</dt><dd><input type="text" name="w100" id="w100" size="5">px</dd>
</dl>
<input type="button" value="Set" onclick="set();">
</form>
<div class="box"></div>
This is a jquery that I just wrote.Please let me know how to put the obtained value in 100% width of keyframe.
function set(){
get vara=$("#w100").val(); // value
varb = a + "px"; // give a unit
$("div").addClass("c");
}
The CSS below is when the input value is 200.
<style>
.box {margin:10px;padding:0;height:50px;background:#fcc;
animation-name —anim;
animation-duration:3s;
animation-timin-function:ease-in;
animation-delay:1s;
animation-fill-mode:both;
- webkit-animation: a 3sease-in 1s both;
}
.c{
@keyframesanim{
0% {height:50px;width:50px;}
100% {height:50px;width:200px;}
}
}
</style>
jQuery.KeyFrames Plug-in with $.keyframe.define()
allows you to define keyframe parameters as follows:
下 Click the Run Snippet button below to see the results.
function set(){
var width=$("#w100").val();
variationName='anim_'+width;
$.keyframe.define([{]
name —animationName,
'0%': {
'height': '50px',
'width': '50px'
},
'100%': {
'height': '50px',
'width': width + 'px'
}
}]);
$(".box").playKeyframe({
name —animationName,
duration: '3s',
timingFunction: 'ease-in',
delay: '1s',
fillMode: 'both'
});
}
.box{
margin —10px;
padding:0;
height —50px;
background: #fcc;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/jQueryKeyframes/jQuery.Keyframes/master/jquery.keyframes.min.js"></script>
<dl>
<dt>0%</dt>
<dd>50px</dd>
<dt>100%</dt>
<dd>
<input type="text" name="w100" id="w100" size="5" value="400">px</dd>
</dl>
<input type="button" value="Set" onclick="set();">
</form>
<div class="box"></div>
585 PHP ssh2_scp_send fails to send files as intended
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
615 GDB gets version error when attempting to debug with the Presense SDK (IDE)
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.