如何根据当前页面突出显示链接? [英] How do I highlight a link based on the current page?

查看:120
本文介绍了如何根据当前页面突出显示链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,如果这听起来像一个非常愚蠢的问题,但我需要让链接改变颜色,当你在它链接到的页面。

Sorry if this sounds like a really stupid question, but I need to make a link change color when you are on the page it links to.

当你在stackoverflow的问题页面时,顶部的链接会更改颜色。

For example, when you are on the "Questions" page of stackoverflow, the link at the top changes color. How do you do this?

推荐答案

这是一个服务器端的事情 - 在渲染页面时,添加一个类current -page到链接。

It's a server-side thing -- when rendering the page, add a class like "current-page" to the link. Then you can style it separately from the other links.

例如,StackOverflow使用 class =youarehere当它指向您已经在上的网页。

For example, StackOverflow renders the links with class="youarehere" when it points to the page you're already on.

这篇关于如何根据当前页面突出显示链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆