You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET框架下如何更改导航栏的字体颜色?

How to Change Navbar Text Color in ASP.NET Web Application (.NET Framework)

Hey there! I’ve worked with the default ASP.NET Web Forms template plenty of times, so let me walk you through changing that navbar text color easily.

Since you already know your way around Site.css and Site.Master, we’ll focus on the CSS approach (the cleanest and most maintainable way):

  • Open your Content/Site.css file
  • Add the following CSS rules at the bottom of the file (so they override any default Bootstrap styles):
/* Default navbar link color */
.navbar-inverse .navbar-nav > li > a {
    color: #f0f0f0; /* Replace with your desired color, e.g., #ffffff for white */
}

/* Hover/focus state for navbar links */
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
    color: #ffd700; /* Change this to your preferred hover color */
}

/* Active (current page) navbar link color */
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
    color: #ffffff; /* Set the color for the active tab */
}

/* Optional: Change the brand name text color */
.navbar-inverse .navbar-brand {
    color: #f0f0f0; /* Match or set a different color for the app name */
}

Why this works:

The default template uses Bootstrap’s .navbar-inverse class for the navigation bar. By targeting the specific child elements (navbar-nav > li > a) in your Site.css, you’re overriding Bootstrap’s default color styles—since Site.css loads after Bootstrap’s stylesheet in the template, your custom rules will take priority.

If you ever need to tweak specific links (like the login/register ones), you can add more targeted rules, but the above covers all standard navbar text elements.

内容的提问来源于stack exchange,提问作者Zalgawi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:28:11