欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > CSS ——相关链接制作

CSS ——相关链接制作

2025/11/9 7:55:52 来源:https://blog.csdn.net/qq_53810245/article/details/143141643  浏览:    关键词:CSS ——相关链接制作

文章目录

    • 需求
    • 分析
      • 代码
      • 注意

需求

制作一个相关链接

在这里插入图片描述

分析

代码

  • html
<div class="box"><div class="title"><span>相关链接</span></div><div class="links"><span><a href="https://www.baidu.com" target="_blank">网址111</a></span>|<span><a href="https://www.baidu.com" target="_blank">网址222</a></span></div></div>
  • css
.box {width: 100%;margin: 10px 0;}.title {height: 42px;margin-top: 10px;background: url("../src/assets/images/dashboard/bg-title.png") no-repeat;/* background: url("@/assets/images/dashboard/bg-title.png") no-repeat; */background-size: 100% 100%;letter-spacing: 5px;display: flex;justify-content: space-between;>span {font-size: 18px;font-family: "YouSheBiaoTiHei";margin-left: 44px;color: #F4FBFF;font-weight: bold;line-height: 33px}}.links {height: 70%;color: #fff;font-size: medium;display: flex;justify-content: center;align-items: center;span {margin: 0 10px;a {text-decoration: underline;text-underline-offset: 5px;/* 设置下划线与文字的距离 */color: inherit;}a:hover {color: #015293;}}}
<!DOCTYPE html>
<html lang="zh"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>相关链接示例</title><style>body {background-color: #015293;}.box {width: 100%;margin: 10px 0;}.title {height: 42px;margin-top: 10px;background: url("../src/assets/images/dashboard/bg-title.png") no-repeat;/* background: url("@/assets/images/dashboard/bg-title.png") no-repeat; */background-size: 100% 100%;letter-spacing: 5px;display: flex;justify-content: space-between;>span {font-size: 18px;font-family: "YouSheBiaoTiHei";margin-left: 44px;color: #F4FBFF;font-weight: bold;line-height: 33px}}.links {height: 70%;color: #fff;font-size: medium;display: flex;justify-content: center;align-items: center;span {margin: 0 10px;a {text-decoration: underline;text-underline-offset: 5px;/* 设置下划线与文字的距离 */color: inherit;}a:hover {color: #015293;}}}</style>
</head><body><div class="box"><div class="title"><span>相关链接</span></div><div class="links"><span><a href="https://www.baidu.com" target="_blank">网址111</a></span>|<span><a href="https://www.baidu.com" target="_blank">网址222</a></span></div></div>
</body></html>

注意

  1. a 标签点击后开启新的窗口

a标签打开新窗口 只需要在a标签后面加 target=“_blank”

<a href="index.html" target="_blank">跳转到新窗口打开</a>

扩展:a标签后面加 target=“_self” 是此窗口默认打开 (这个属性是默认的)

<a href="index.html" target="_self">此窗口打开</a>
  1. a 标签点击后的文字颜色
a {text-decoration: none; /* 去除下划线 */color: inherit; /* 继承父元素颜色 */
}
a:visited {color: inherit; /* 访问后颜色 */
}
a:active {color: inherit; /* 点击时颜色 */
}
a:hover {color: inherit; /* 悬停时颜色 */
}
  1. a 标签的下划线如何离文字一定距离
a {text-decoration: underline;text-underline-offset: 5px; /* 设置下划线与文字的距离 */text-decoration-thickness: 2px; /* 设置下划线的粗细 */
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词