如何将常规文本和动画文本放在同一行?

时间:2014-07-13 11:07:43

标签: html

如何将所有内容放在同一行?见http://jsfiddle.net/zQ5AL/4/

它不适用于2个<p>代码

非常感谢

HTML

<p>The number is <p id="dynamic-number">1</p> . Please confirm</p>

JS

var currentNumber = $('#dynamic-number').text();

$({numberValue: currentNumber}).animate({numberValue: 900}, {
    duration: 2000,
    easing: 'swing',
    step: function() { 
        $('#dynamic-number').text(Math.ceil(this.numberValue)); 
    }
});

4 个答案:

答案 0 :(得分:0)

p标签内不能有p标签。尝试:

<p>The number is <span id="dynamic-number">1</span> . Please confirm</p>

答案 1 :(得分:0)

只需使用span元素

<p>The number is <span id="dynamic-number">1</span> . Please confirm</p>

答案 2 :(得分:0)

检查出来:

http://jsfiddle.net/zQ5AL/5/

这里是你小提琴的更新......

溶液:

<p>The number is <span id="dynamic-number">1</span> . Please confirm</p>

答案 3 :(得分:0)

试试这个:

我添加了几个css:

#dynamic-number {
   color: #000;
    font: bold 35px Arial;
    margin-top: -10px;
    padding: 0 4px;
    text-align: center; 
}
p {  margin:0;padding:0;float:left;}

删除margin,padding并设置float:left

Here is the Working Demo