懸浮數(shù)字的實(shí)現(xiàn)案例

原理是什么呢?
1.獲取數(shù)字或者狀態(tài)。
function getnewscount(){
$time = date("Y-m-d",strtotime("-3 day"));
$where["News.checkked = ?"] = array("val"=>1 , "type"=>1);
$where["News.UpdateTime >= ?"] = array("val"=>$time,"type"=>1);//'2014-01-10'
$news = $this->dao_news->getNews($where);
return count($news);
}
function getstatus($user_id){
$where["lx_messageto.user_id = ?"] = array("val"=>$user_id , "type"=>1);
$where["lx_messageto.status = ?"] = array("val"=>1,"type"=>1);
$message = $this->dao_message->getMessageTo($where);
return count($message);
}
2.前端處理顯示。用js處理。
<div style="position:absolute;" class="status1">
<!--{if $statusCount neq ""}-->
<div class="status_num">
<!--{$statusCount}-->
</div>
<!--{/if}-->
</div>
<div style="position:absolute;" class="status2">
<!--{if $newsCount neq ""}-->
<div class="status_icon">
<img src="/images/common/new.png">
</div>
<!--{/if}-->
</div>
css
.status_num{
position:absolute;
left:70px; top:0px;
background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgba(234, 87, 122, 1)), to(rgba(136, 4, 25, 1)));
height:30px; line-height:30px;
vertical-align:middle;
font-family:Verdana, Geneva, sans-serif; color:#fff;
font-size:14px;-webkit-border-radius:30px;
padding:0px 10px; margin-left:20px;
-webkit-box-shadow:1px 1px 3px #999;}
.status_icon{
position:absolute;
left:70px; top:0px;
}
js處理
$(function() {
aMess = $("a[href ^= '/message']");
aNews = $("a[href ^= '/news/index']");
var status = $(".status1");
var statusnews = $(".status2");
aNews.prepend(statusnews);
aMess.prepend(status); //處理消息的
});
3.或者用ajax獲取數(shù)據(jù)ajax處理
$(function() {
if( $("a[href *= '/news/mgr']") != " " ){
aNews = $("a[href *= '/news/mgr']") ;
$.ajax({
dataType:'html',
type:"POST",
url:"/default/index/ajaxgetnewstatus",
success:function(msg){
if(msg > 0){
var num = '<div style="position:absolute;" class="status1">'
+'<div class="status_num">'+msg+'</div></div>';
aNews.prepend(num);}
}
});
};
});
相關(guān)文章
javascript 判斷中文字符長(zhǎng)度的函數(shù)代碼
在很多時(shí)候,我們?cè)谶M(jìn)行數(shù)據(jù)提交數(shù)據(jù)庫(kù)時(shí).先會(huì)用javascript對(duì)其進(jìn)行有效性驗(yàn)證.如一個(gè)中文javascript為的length是1.但是數(shù)據(jù)庫(kù)中會(huì)占二個(gè)字節(jié).容易出錯(cuò)2012-08-08Web打印解決方案之證件套打的實(shí)現(xiàn)思路
這篇文章主要介紹了Web打印解決方案之證件套打的實(shí)現(xiàn)思路的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08