1. 论坛系统升级为Xenforo,欢迎大家测试!
    Dismiss Notice

请教XHTML的一个问题

Discussion in '前端开发' started by wuhao, Mar 12, 2008.

  1. wuhao

    wuhao New Member

    Joined:
    May 23, 2006
    Messages:
    265
    Likes Received:
    0
    就是导航拦,我设置连接颜色全部都是黑色,但有一个连接我想做成红色,我这么做的
    <a href="#" class="red">aaa</a>

    然后css里写 .red{color:red;}

    但是不起效果,一般一堆连接,对某几个连接作用单独的效果该怎么做呀,

    <a href="#" title="xxx"><font color=red>xxx(HOT)</font></a><br />这样虽然可以,但是不符合规范呀,请大家指教,请老鬼赐教!
     
  2. wuhao

    wuhao New Member

    Joined:
    May 23, 2006
    Messages:
    265
    Likes Received:
    0
    HTML:
    <style>
    a{color:#000}
    .red {color:red;}
    </style>
    <a href="#" class="red">aaa</a>
    <a href="#">aaa</a>
    别人的貌似可以
     
  3. wuhao

    wuhao New Member

    Joined:
    May 23, 2006
    Messages:
    265
    Likes Received:
    0
    问题解决

    解决方法如下

    没人回答偶也得把方法写上帮助后人,哈哈

    <html>
    <style>
    a:link { color: #000;text-decoration: none;}
    a:visited { color: #000;text-decoration: none;}
    a:hover { color: #000; text-decoration: underline;}
    a.b:link { color: #f00;text-decoration: none;}
    a.b:visited { color: #f00;text-decoration: none;}
    a.b:hover { color: #000; text-decoration: underline;}
    </style>
    <a href="#" class="b">aaa</a>
    <a href="#">aaa</a>
    </html>
     
  4. 风

    New Member

    Joined:
    Sep 5, 2005
    Messages:
    145
    Likes Received:
    0
    定义的顺序问题吧。

    一般针对元素的选择器,应该写在靠前的位置,特别的类选择器,定义在靠后,以覆盖之前的元素选择器的定义。
     
  5. zipo_han

    zipo_han New Member

    Joined:
    Jul 8, 2006
    Messages:
    112
    Likes Received:
    0
    <html>
    <style>
    a:link,a:visited { color: #000;text-decoration: none;}
    a:hover {text-decoration: underline;}
    a.b:link,a.b:visited { color: #f00;text-decoration: none;}
    a.b:hover {text-decoration: underline;}
    </style>
    <a href="#" class="b">aaa</a>
    <a href="#">aaa</a>
    </html>


    至少应该这么写的,:belial: