- 时间:2020-11-08 13:49 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:jQuery+ajax实现顶一下,踩一下效果
demo页面的实现
[url=#]<p>这个文档不错</p>
<div class="bar">
<div id="g_img" style="width:70%"></div>
</div>
<span class="num" id="num">70%(7000)</span> </a> </div>
<div class="bad"> <a href="#">
<p>文档有待改进</p>
<div class="bar">
<div id="b_img" style="width:30%"></div>
</div>
<span class="num">30%(3000)</span> </a> </div>
</div>
主要一点就是通过百分比来控制g_img的宽度,至于css代码就不贴出来了。
演示代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Digg</title>
<style type="text/css">
* {
padding:0;
margin:0;
}
.digg {
height: auto;
width: 190px;
font-size:12px;
font-weight:normal;
}
.digg a {
display: block;
height: 48px;
width: 189px;
background-image: url(images/mark.gif);
background-repeat: no-repeat;
position: relative;
color: #000;
text-decoration: none;
}
.digg .good {
margin-bottom:10px;
margin-top:5px;
}
.digg .good a {
background-position: -189px 0px;
}
.digg .good a:hover {
background-position: 0px 0px;
}
.digg .bad a {
background-position: -378px 0px;
}
.digg .bad a:hover {
background-position: -567px 0px;
}
.digg a p {
padding-left:30px;
line-height:25px;
}
.digg .bar {
background-color: white;
height: 5px;
left: 20px;
overflow: hidden;
position: absolute;
text-align: left;
top: 30px;
width: 55px;
}
.bar #g_img {
background-image: url(images/sprites.gif);
background-repeat: repeat-x;
height: 5px;
width: auto;
}
.bar #b_img {
background-image: url(images/sprites.gif);
background-repeat: repeat-x;
height: 5px;
width: auto;
background-position: 0px -5px;
}
.num {
color: #333;
font: normal normal 100 10px/12px Tahoma;
left: 80px;
position: absolute;
top: 26px;
}
.digg .good .bar {
border: 1px solid #40A300;
}
.digg .bad .bar {
border: 1px solid #555;
}
</style>
</head>
<body>
<div class="digg" id="digg">
<div class="good"> <a href="#">
<p>这个文档不错</p>
<div class="bar">
<div id="g_img" style="width:70%"></div>
</div>
<span class="num" id="num">70%(7000)</span> </a> </div>
<div class="bad"> <a href="#">
<p>文档有待改进</p>
<div class="bar">
<div id="b_img" style="width:30%"></div>
</div>
<span class="num">30%(3000)</span> </a> </div>
</div>
</body>
</html>
有了demo,其他实现起来就方便多了,首先是页面获取html,页面第一次加载,用ajax获取后台数据,不要直接显示。(这里为了方便测试,就用asp作为后台语言)
下面是asp输出html代码
[url=http://www.1sucai.cn/jiaoben/28489.html]http://www.1sucai.cn/jiaoben/28489.html[/url]