首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • css里a和a:visited的分别? [已结贴,结贴人:hackem]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • hackem
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 揭帖率:
    发表于:2008-05-18 18:06:16 楼主
    #nav li a:visited {
    color:#000000;
    text-decoration:none;
    }
    #nav li a:hover,#nav .current_page_item a, #nav .current_page_item a:visited {
    background:#2E91C6 url(nav-item-hover.gif) repeat-x scroll 0%;
    color:#FFFFFF;
    text-decoration:none;
    }
    ==
    上面这代码,
    第二句CSS块为了不让a标签继承li a:visited的属性设置,所以设置了.current_page_item a:visited让字体颜色不同。
    但在第二句CSS块里不是有了.current_page_item a的定义么?
    而定义了a不就代表定义了其下的hover visited,link都使用它设置的属性值么?


    a
    {color:red;}
    不就等于下面定义的总和么?
    a:link{color:red;} 
    a:visited{color:red;}
    a:hover {color:red;}
    a:active {color:red;}

    而上面的
    #nav .current_page_item a定义不就已包含了.current_page_item a:visited的定义么?为什么还要写多一次?
    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • mumuTiger
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-05-18 19:02:251楼 得分:78
    楼主可以看下
    下面2段代码 呵呵!


    1.

    <style>
    a{color:green;}
    a:link{color:red}
    a:visited{color:yellow}
    </style>
    <a href="http://g.cn">eqeqeqeqeq </a>

    2.

    <style>
    a{color:green;}
    a:link{color:red}
    a:visited{color:yellow}
    </style>
    <a >eqeqeqeqeq </a>

    理解下 a和a:link
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • chinmo
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      6

    发表于:2008-05-18 19:27:202楼 得分:3
    区别你已经知道了吧
    你是想问区别还是多写原因
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • hery2002
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      2

    发表于:2008-05-18 20:18:103楼 得分:2
    引用 2 楼 chinmo 的回复:
    区别你已经知道了吧
    你是想问区别还是多写原因

    估计只是多写一下而已,
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • wangbo_wb
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-05-18 21:09:434楼 得分:2
    这个例子做得太好了

    引用 1 楼 mumuTiger 的回复:
    楼主可以看下 
    下面2段代码 呵呵!


    1. 

      <style>
    a{color:green;}
    a:link{color:red}
    a:visited{color:yellow}
    </style>
    <a href="http://g.cn">eqeqeqeqeq </a>

    2. 

    <style>
    a{color:green;}
    a:link{color:red}
    a:visited{color:yellow}
    </style>
    <a >eqeqeqeqeq </a>

    理解下 a和a:link
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • vising
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-05-19 01:41:515楼 得分:15
    第一句是#nav li,和下面的不一样啊
    是#nav li下专用的
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • hackem
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-05-19 19:57:506楼 得分:0
    灌水有意思么?
    在CSS Creator里问回来的,或许对一些朋友有帮助。

    the coder is overriding the basic styles for :hover so that the buttons or whatever they are look different when someone hovers. Makes sense. The other two look like a "You Are Here" style-- meaning that in the whole menu, there is a menu item that should always look hovered-- even if it's been visited before. So there's a class on a single menu item called .current_page_item showing the visitor which page they're on by giving that item a highlight.

    To make that change with every page (since it should be on a different menu item on different pages), lots of people use an id on the body. body id="home" or whatever, then the Home button on the menu would have the current_page_item class on it, and would tell visitors that they were back on the Home page. For instance.

    They do, you are correct. You do NOT need all those declarations because "a" will make the rest the same. You only need to list :hover, :visited, etc. IF you want them different.

    I think maybe you have all these extra declarations because this is a template. The writers of templates don't know what you will want to change, so they write all this extra code so that, if you wanted to change .current_page_item's :visited state, for example, then it's already there for you to edit.
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved