网页超链接:主页与子页的具体链接

学习链接:网页超链接,包括从子页到首页的进入返回

简单思路是:主页面的超链接是两个子页面,子页面的超链接是首页,以达成互相链接的效果

注意事项:因为子页面在other文件下,所以有文件夹的跳入跳出,如果忽略此步,会造成无法访问。跳入文件夹用“文件夹名/”,跳出文件夹用“../”

最终文件有三个,other文件下是page1.html,page2.html,以及other文件夹外的page.html文件

最终效果:

主页面源码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main{
            width: 200px;
            height: 200px;
            background-color: orange;
            margin: auto;
        }
        .ysa{
            width: 200px;
            height: 140px;
            font-size: 20pt;
            text-align: center;
            line-height: 140px;
        }
        .ysb{
            width: 200px;
            height: 60px;
            line-height: 30px;
            text-align: center;
        }
        a{
            /* 超链接标签 */
            text-decoration: none;
            /* 去掉超链接文本的下划线 */
            color:blue;
        }
        a:hover{
            /* 鼠标悬停时超链接字体变色 */
            color: red;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="ysa">首页</div>
        <div class="ysb">
            <!-- 将子页面的网页放到other文件夹里,若直接href是page1无法访问 -->
            <!-- 跳入文件夹用“文件夹名/”,跳出文件夹用“../” -->
            <a href="other/page1.html">点我跳到子页面1</a><br>
            <a href="other/page2.html">点我跳到子页面2</a>
        </div>
    </div>
</body>
</html>

子页面1源码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main{
            width: 200px;
            height: 200px;
            background-color: orange;
            margin: auto;
        }
        .ysa{
            width: 200px;
            height: 140px;
            font-size: 20pt;
            text-align: center;
            line-height: 140px;
        }
        .ysb{
            width: 200px;
            height: 60px;
            line-height: 30px;
            text-align: center;
        }
        a{
            /* 超链接标签 */
            text-decoration: none;
            /* 去掉超链接文本的下划线 */
            color:blue;
        }
        a:hover{
            /* 鼠标悬停时超链接字体变色 */
            color: red;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="ysa">子页1</div>
        <div class="ysb">
            <!-- ..意思是跳出当前文件夹,否则无法实现从子页回到首页效果 -->
            <a href="../page.html">点我回到首页</a><br>
        </div>
    </div>
</body>
</html>

子页2的源码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main{
            width: 200px;
            height: 200px;
            background-color: orange;
            margin: auto;
        }
        .ysa{
            width: 200px;
            height: 140px;
            font-size: 20pt;
            text-align: center;
            line-height: 140px;
        }
        .ysb{
            width: 200px;
            height: 60px;
            line-height: 30px;
            text-align: center;
        }
        a{
            /* 超链接标签 */
            text-decoration: none;
            /* 去掉超链接文本的下划线 */
            color:blue;
        }
        a:hover{
            /* 鼠标悬停时超链接字体变色 */
            color: red;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="ysa">子页2</div>
        <div class="ysb">
            <a href="../page.html">点我回到首页</a><br>
        </div>
    </div>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值