我想做出这样的效果,图如下:但是,我的代码把那个图片提示给省略了,我想问一下应该怎么修改?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
.li_title { list-style-type:none;
height:24px;
font-size:12px;
line-height:24px;
width:310px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
background:url(http://upload.ouliu.net/h/61c91df2639493a3f3656e1b8ba602ec.gif) no-repeat left center;
padding-left:12px;
}
.li_title a { list-style-type:none;
font-size:12px;
line-height:24px;
height:24px;
width:200px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
display:block;
}
.date {float:right;margin-right:3px;}.clear {clear:both;visibility:hidden;}
</style>
</HEAD> <BODY>
<div id="Conttab_p_switch1" style="width:310px;float:left;">
<UL id="sometest">
<LI class="li_title"><span class="date">2011-04-23</span><A title=新疆将接回所有在外省流浪儿童 提供免费培训 href="#" target=_blank>新疆将接回所有在外省流浪儿童 提供免费培训</A></LI>
<LI class="li_title"><span class="date">2011-04-11</span><A title=药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万 href="#" target=_blank>药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万</A></LI>
<LI class="li_title "><span class="date">2011-04-04</span><A title=李庄漏罪案法庭裁定准许检方撤回起诉 href="#" target=_blank>李庄漏罪案法庭裁定准许检方撤回起诉</A></LI>
</UL>
<div class="clear"></div>
</div>
<script>
window.onload = function(){
var lis = document.getElementById("sometest").getElementsByTagName("li");
var now = new Date();
for(var i = 0 ;i<lis.length ;i++){
var arr = lis[i].childNodes[0].innerHTML.split("-");
var t = new Date(arr[0],parseInt(arr[1])-1,arr[2]);
if(now.getFullYear()==t.getFullYear()&&now.getMonth()==t.getMonth()&&now.getDate()==t.getDate()){
var img = "<img src='http://upload.ouliu.net/h/70b18c2113f90e2920b290ee468904d5.gif'/>";
lis[i].innerHTML+=img;
}
}
}
</script>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
.li_title { list-style-type:none;
height:24px;
font-size:12px;
line-height:24px;
width:310px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
background:url(http://upload.ouliu.net/h/61c91df2639493a3f3656e1b8ba602ec.gif) no-repeat left center;
padding-left:12px;
}
.li_title a { list-style-type:none;
font-size:12px;
line-height:24px;
height:24px;
width:200px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
display:block;
}
.date {float:right;margin-right:3px;}.clear {clear:both;visibility:hidden;}
</style>
</HEAD> <BODY>
<div id="Conttab_p_switch1" style="width:310px;float:left;">
<UL id="sometest">
<LI class="li_title"><span class="date">2011-04-23</span><A title=新疆将接回所有在外省流浪儿童 提供免费培训 href="#" target=_blank>新疆将接回所有在外省流浪儿童 提供免费培训</A></LI>
<LI class="li_title"><span class="date">2011-04-11</span><A title=药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万 href="#" target=_blank>药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万</A></LI>
<LI class="li_title "><span class="date">2011-04-04</span><A title=李庄漏罪案法庭裁定准许检方撤回起诉 href="#" target=_blank>李庄漏罪案法庭裁定准许检方撤回起诉</A></LI>
</UL>
<div class="clear"></div>
</div>
<script>
window.onload = function(){
var lis = document.getElementById("sometest").getElementsByTagName("li");
var now = new Date();
for(var i = 0 ;i<lis.length ;i++){
var arr = lis[i].childNodes[0].innerHTML.split("-");
var t = new Date(arr[0],parseInt(arr[1])-1,arr[2]);
if(now.getFullYear()==t.getFullYear()&&now.getMonth()==t.getMonth()&&now.getDate()==t.getDate()){
var img = "<img src='http://upload.ouliu.net/h/70b18c2113f90e2920b290ee468904d5.gif'/>";
lis[i].innerHTML+=img;
}
}
}
</script>
</BODY>
</HTML>
解决方案 »
- 如何用两个属性结合起来选中一个span标签?
- javascript鼠标三击事件
- 求助
- popup的document.body.scrollHeight问题。
- 急、急、急请大家帮忙!!!
- javascript 中的字符串函数,请求帮助。
- 我要判断一个新窗口 w=window.open("ddd.html") 中是否有这个变量ww[1],请问如何写代码呢?
- 请教用 vbs 或 js 如何获得 IE 状态栏的系统信息
- 如何控制IE当中的“文件”菜单下的“页面设置”的内容???急!
- jquery的autoComplete正则表达式中如何修改为只匹配开头的字母?
- setTimeout执行的问题
- 关于ext 数据显示问题
li
{
padding-right:20px;
background:url(你的图片的url) left top;
}
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
.li_title { list-style-type:none;
height:24px;
font-size:12px;
line-height:24px;
width:310px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
background:url(http://upload.ouliu.net/h/61c91df2639493a3f3656e1b8ba602ec.gif) no-repeat left center;
padding-left:12px;
}
.li_title a { list-style-type:none;
font-size:12px;
line-height:24px;
height:24px;
width:200px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
display:block;
}
.date {float:right;margin-right:3px; padding-left:20px;background:url(http://upload.ouliu.net/h/70b18c2113f90e2920b290ee468904d5.gif) left top no-repeat;}.clear {clear:both;visibility:hidden;}
</style>
</HEAD> <BODY>
<div id="Conttab_p_switch1" style="width:310px;float:left;">
<UL id="sometest">
<LI class="li_title"><span class="date">2011-04-23</span><A title=新疆将接回所有在外省流浪儿童 提供免费培训 href="#" target=_blank>新疆将接回所有在外省流浪儿童 提供免费培训</A></LI>
<LI class="li_title"><span class="date">2011-04-11</span><A title=药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万 href="#" target=_blank>药家鑫犯故意杀人罪被判死刑 民事赔偿4.5万</A></LI>
<LI class="li_title "><span class="date">2011-04-04</span><A title=李庄漏罪案法庭裁定准许检方撤回起诉 href="#" target=_blank>李庄漏罪案法庭裁定准许检方撤回起诉</A></LI>
</UL>
<div class="clear"></div>
</div>
<script>
window.onload = function(){
var lis = document.getElementById("sometest").getElementsByTagName("li");
var now = new Date();
for(var i = 0 ;i<lis.length ;i++){
var arr = lis[i].childNodes[0].innerHTML.split("-");
var t = new Date(arr[0],parseInt(arr[1])-1,arr[2]);
if(now.getFullYear()==t.getFullYear()&&now.getMonth()==t.getMonth()&&now.getDate()==t.getDate()){
var img = "<img src='http://upload.ouliu.net/h/70b18c2113f90e2920b290ee468904d5.gif'/>";
lis[i].innerHTML+=img;
}
}
}
</script>
</BODY>
</HTML>
这样行不行,你在日期元素容器动动脑筋。如果是当前日期的话,就在span元素里设置左填充,然后添加背景图片。
希望你能明白我的需求,我用那段js是验证span里的日期,如果,是当天,就动态地添加一个new的图片提示。
.li_title a {
list-style-type:none;
font-size:12px;
line-height:24px;
height:24px;
width:200px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis; /* 文字省略号 for IE */
-o-text-overflow: ellipsis; /*文字省略号 for Opera */
/*display:block;*/ /*这个地方去掉或者改为 display:inline; 试试*/
}
你那个修改在ie6下可以,但是不兼容chrome.我知道怎么处理了。应该那个列表的点是用img,而那个new图片提示用background。