自动刷新div进入下一行

时间:2015-08-28 00:15:37

标签: jquery html css

我有一个带有jquery和slim框架的简单代码,这里是:

jquery的:

var auto_refresh = setInterval(
function ()
{
$('#counter').load('/requests/autoloader').fadeIn("slow");
}, 5000);

/requests/autoloader路线

$stat = 1;
$requests = $dbh->prepare("SELECT COUNT(*) FROM encashments WHERE status = ? ");
$requests->execute(array($stat));
$reqs = $requests->fetchColumn();
echo $reqs;

我的HTML:

<li role="presentation"><a href="/user/admin/encashment/requests">Encashment Requests <div id="counter" style="color:red;"></div></a></li>

一切都运转良好,但我想知道为什么div移动到下一行?看起来像这样: enter image description here

正如您所看到的,该数字低于Encashment Requests链接,我希望它只是在它旁边。我该怎么做?谢谢。

1 个答案:

答案 0 :(得分:2)

尝试将#counter css财产display设为inline-block

&#13;
&#13;
#counter {
  display:inline-block;
}
&#13;
<li role="presentation"><a href="/user/admin/encashment/requests">Encashment Requests <div id="counter" style="color:red;">3</div></a></li>
&#13;
&#13;
&#13;