设置页脚链接样式后博客文章文本变白的技术咨询
问题原因
你的CSS选择器a:link、a:visited、a:hover是全局生效的,会匹配页面中所有的<a>标签,所以博客文章里的链接也被强制改成了白色。
解决方案
给CSS选择器加上footer前缀,让样式仅作用于页脚内部的链接:
footer a:link { color: White; background-color: transparent; text-decoration: none; } footer a:visited { color: White; background-color: transparent; text-decoration: none; } footer a:hover { color: White; background-color: transparent; text-decoration: underline; }
你的HTML代码无需修改,保持原样即可:
<footer> <a href="https://tasteveryday.com/"><h5>Home</h5></a><a href="https://tasteveryday.com/about-us/"><h5>About Us</h5></a><a href="https://tasteveryday.com/contact/"><h5>Contact</h5></a><a href="https://tasteveryday.com/privacy-policy/"><h5>Privacy Policy</h5></a><a href="https://tasteveryday.com/term-of-use/"><h5>Terms Of Use</h5></a> </footer>
修改后,只有页脚内的链接会应用白色样式,博客文章中的链接不会再被影响。
内容的提问来源于stack exchange,提问作者Souhail Hajib
相关产品推荐
相关产品推荐

