Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何将活动css类添加到菜单项?_Html_Css_Twitter Bootstrap - Fatal编程技术网

Html 如何将活动css类添加到菜单项?

Html 如何将活动css类添加到菜单项?,html,css,twitter-bootstrap,Html,Css,Twitter Bootstrap,在本例中,为什么Home按钮没有标记为红色 .navbar a:悬停, .导航栏a:聚焦, .导航栏a:活动{ 颜色:红色!重要; } 我想应该是这样的: navbar a:hover { color:red; font-weight:bolder; text-decoration:underline; } 我觉得应该是这样的, navbar a:hover { color:red; font-weight:bolder; text-decoration:underline; } 您不应该

在本例中,为什么
Home
按钮没有标记为红色

.navbar a:悬停,
.导航栏a:聚焦,
.导航栏a:活动{
颜色:红色!重要;
}

我想应该是这样的:

navbar a:hover {
color:red;
font-weight:bolder;
text-decoration:underline;
}

我觉得应该是这样的,

navbar a:hover {
color:red;
font-weight:bolder;
text-decoration:underline;
}

您不应该使用
a:active
而是
a.active

:在
之后是一个伪类。但是您要选择
一个也有
.active
类的
标记

.navbar a:悬停,
.导航栏a:聚焦,
.导航栏a.激活{
颜色:红色!重要;
}

您不应该使用
a:active
而是
a.active

:在
之后是一个伪类。但是您要选择
一个也有
.active
类的
标记

.navbar a:悬停,
.导航栏a:聚焦,
.导航栏a.激活{
颜色:红色!重要;
}

使用css

CSS类选择器根据元素的内容匹配元素 类属性

.navbar a.active{
颜色:红色;
}

使用css

CSS类选择器根据元素的内容匹配元素 类属性

.navbar a.active{
颜色:红色;
}

为什么它不是活动的,而是活动的


使用
.active
来引用,而不是
a:active
,在这种情况下,您还可以阅读有关选择器的更多信息

为什么它不是active,而是active


使用
.active
来引用,而不是
a:active
,在这种情况下,您还可以阅读有关选择器的更多信息,只需键入:
a.active
而不是/除了
a:active
。只需键入:
a.active
而不是/除了
a:active