用ASP程序模拟实现first-child的功能


first-child用来设置对象(Selector1)的第一个子对象(Selector2)的样式表属性。比如一个列表第一行的样式可以和其他行有所不同,但目前IE尚不支持此伪类。下面给出用ASP模拟实现的方法.

  今看到经典里在讨论这个问题,Realazy的做法是采用了javascript,zbm2001z的做法是用了expression,我想如果这个列表是从数据库读出来的话,用程序写可能更容易。我不是什么程序员,只会一点最简单的asp,如写的不好, 还请多多指导谅解!

  asp代码以下是引用片段:

  '数据库连接代码

 response.write"<ulclass='fgList'>"
 rs.movefirst 
 response.write"<liclass='firstchild'><atitle=''href='#'>"&rs("列表标题")&"</a></li>"
 rs.movenext
 dowhilenot(rs.eoforerr)
 response.write"<li><atitle=''href='#'>"&rs("列表标题")&"</a></li>"
 rs.moveNext
 loop
 response.write"</ul>"
 response.write"<hr/>" CSS Code以下是引用片段:
ul.fgList{
  list-style:none;  
}
ul.fgLista{
  color:#333333;
  background:url(/img/arrow_l2.gif)no-repeat050%;
  padding-left:1.5em;
  line-height:2em;
  text-decoration:none;
}
ul.fgLista:hover{
  color:#999999;
  text-decoration:underline;
  background:inherit;
}
ul.fgListli.firstchilda{
  color:#C00;
  background:url(/img/arrow_l2_over.gif)no-repeat050%;
}
h3{
  font-size:120%;
  padding:2em1em.3em.3em;
}


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3