您现在的位置: 网页制作教程网 >> 网络编程 >> Asp教程 >> ASP实例教程 >> 文章正文

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

作者:forest53…

来源:forest53.com

热度:

2006-10-20 9:57:52

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

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

asp代码
以下是引用片段:
  '数据库连接代码
  response.write "<ul class='fgList'>"
  rs.movefirst 
  response.write "<li class='firstchild'><a title='' href='#'>"&rs("列表标题")&"</a></li>"
  rs.movenext
  do while not (rs.eof or err)
  response.write "<li><a title='' href='#'>"&rs("列表标题")&"</a></li>"
  rs.moveNext
  loop
  response.write "</ul>"
  response.write "<hr />"
CSS Code
以下是引用片段:
ul.fgList{
    list-style: none;    
}
ul.fgList a{
    color: #333333;
    background: url(/img/arrow_l2.gif) no-repeat 0 50%;
    padding-left: 1.5em;
    line-height: 2em;
    text-decoration: none;
}
ul.fgList a:hover{
    color: #999999;
    text-decoration: underline;
    background: inherit;
}
ul.fgList li.firstchild a{
    color: #C00;
    background: url(/img/arrow_l2_over.gif) no-repeat 0 50%;
}
h3{
    font-size: 120%;
    padding: 2em 1em .3em .3em;
}

我来说两句:

1分 2分 3分 4分 5分
姓名: *


* 请各位网友遵纪守法并注意语言文明。
网站简介 | 联系方式 | 意见建议 | 版权说明
Copyright © 2007 All rights reserved
滇ICP备06006992号