a 标签自己比较少用,但是平时难免会使用到,随手记录一下
去除 a标签的默认样式
a {text-decoration:none;color: black;} a:hover{text-decoration:none; cursor:pointer}/*a标签鼠标经过mouseover时的样式*/ a:link{text-decoration:none; cursor:pointer;} /*a标签未访问时的样式*/ a:visited{text-decoration: overline ; cursor:pointer}/*a标签访问过之后样式*/ a:active{text-decoration:overline;cursor:pointer}/*a标签鼠标按下mousedown时的样式*/
a标签地址的打开方式:
常用的是在新窗口打开:target="_Blank"
<a href="http://www.baidu.com" target="_Blank">target="_Blank" 是在 新窗口 打开百度</a>
<a href="http://www.baidu.com" target="_Self">target="_Self" 是在 自身 打开百度</a>
<a href="http://www.baidu.com" target="_Parent">target="_Parent" 是在 父窗口 打开百度</a>
<a href="http://www.baidu.com" target="_Top">target="_Top" 是在 顶层窗口 打开百度</a>
在指定的 iframe 打开
当然也可以是自己定义的一个 iframe 中,利用 iframe 的名字(name),在 iframe 中打开
<!--当然也可以是自己定义的一个frame 的名字--> <!--比如--> <a href="http://www.baidu.com" target="frame1">百度</a> <iframe name="frame1"></iframe>
如果说,整个网页的 a 标签,都要统一打开方式,
可以在 <head> 中加入 <base target="_blank" />
<head> <base target="_blank" /><!--所有的a在新的页面打开--> </head>
链接会在新窗口中打开,即使链接中没有 target="_blank" 属性。
这是因为 base 元素的 target 属性已经被设置为 "_blank" 了。
关于 base :https://www.w3school.com.cn/tags/tag_base.asp
在 a 标签中,有个容易被忽视的 “ :visited ” 。
a:visited从使用意义来说,是指用户访问过某一个链接之后,该链接的a标签将呈现对应:visited属性定义的样式。
这里的重点在于链接,经过测试发现
<html> <head> <style> a:link{ color:blue; } a:visited{ color:red; } </style> </head> <body> <a id="a1" href="#test1"></a> <a id="a2" href="#test1"></a> <a id="a3" href="#test3"></a> </body> </html>
点击a1之后的同时,a2也会应用visited的样式,但是a3不会。
可以得出这样的结论,a:visited是与URL有关,而与单个的a标签无关
利用这点,我们可以大胆的做一下尝试。
……
(有兴趣的去查看参考资料,个人感觉作用不大)
参考资料(侵删):https://www.cnblogs.com/xueduanyang/archive/2010/11/09/1873110.html