我正在尝试div
根据文本的大小确定动态的高度.我试图在CSS中动态设置它作为我的原始问题/sf/ask/1690537691/?noredirect=1# comment37269329_24150538.
我现在看来有一个JQuery可以让你在https://github.com/jQueryKeyframes/jQuery.Keyframes上这样做.所以我按照他们的示例删除了keyframe
我的CSS
文件并将其包含在脚本中,如下面的代码片段所示:
<body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="/pathToFile/jquery.keyframes.min.js"></script>
<div id="test"> hello</div>
<script>
var supportedFlag = $.keyframe.isSupported();
$.keyframe.define([{
name: 'myfirst',
'0%': {top:$("#test").innerHeight()*-1; left:0px},
'50%': {top:100%; left:0px},
'100%': {top:$("#test").innerHeight()*-1; left:0px}
}]);
$(selector).playKeyframe({
name: 'myfirst', // name of the keyframe you want to bind to the selected element
duration: 90, // [optional, default: 0, in ms] how long you want it to last in milliseconds
timingFunction: 'linear', // [optional, default: ease] specifies the …
Run Code Online (Sandbox Code Playgroud)