超级链接伪类应用实例

摘自《网页开发手记》

1、效果图:


2、html代码:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>超级链接伪类</title>
    <style type="text/css">
        *{
            margin: 0px;
            padding: 0px;
        }
        h3{
            text-align: center;
        }
        #all{
            width: 400px;
            height: 180px;
            margin: 0px auto;
            padding: 10px;
            line-height: 1.8em;
            font-size: 12px;
            background-color: #eee;
            border: 1px solid #000;
        }
        a{
            text-decoration: none;
            position: relative;
            color: #00f;
            font-size: 12px;
        }
        .content{
            display: none;
        }
        a:hover{
            cursor: hand;
            background: #fff;
        }
        a:hover .content, a#aa:link .content, a#aa:visited .content{
            color: #f00;
            display: block;
            position: absolute;
            top: 25px;
            width: 350px;
            height: 150px;
            text-decoration: none;
            color: #000;
            background-color: #ffc;
            border: 1px dashed #fc6;
        }
        a#bb:hover .content{left: -30px;}
        a#cc:hover .content{left: -60px;}
        a#dd:hover .content{left: -90px;}
        a:active{color: #00f;}
        /*a:visited{color: #0f0;}*/
        /*a#aa:link .content{left: 0px;}*/
        a#aa:visited .content{left: 0px;}
    </style>
</head>
<body>
    <h3>门户网站</h3>
    <div id="all">
        <a href="#" id="aa">
            新闻
            <span class="content">
                这是新闻的内容1<hr/>
                这是新闻的内容2<hr/>
                这是新闻的内容3<hr/>
                这是新闻的内容4<hr/>
            </span>
        </a>
        <a href="#" id="bb">
            讨论
            <span class="content">
                这是讨论的内容1<hr/>
                这是讨论的内容2<hr/>
                这是讨论的内容3<hr/>
                这是讨论的内容4<hr/>
            </span>
        </a>
        <a href="#" id="cc">
            留言
            <span class="content">
                这是留言的内容1<hr/>
                这是留言的内容2<hr/>
                这是留言的内容3<hr/>
                这是留言的内容4<hr/>
            </span>
        </a>
        <a href="#" id="dd">
            博客
            <span class="content">
                这是博客的内容1<hr/>
                这是博客的内容2<hr/>
                这是博客的内容3<hr/>
                这是博客的内容4<hr/>
            </span>
        </a>
    </div>
</body>
</html>


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值