相关疑难解决方法(0)

使用JQuery设置CSS关键帧

我正在尝试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)

javascript css jquery css3

11
推荐指数
2
解决办法
3万
查看次数

标签 统计

css ×1

css3 ×1

javascript ×1

jquery ×1