简体   繁体   English

如何在激活时将图像更改为单独的图像?

[英]How to change an image when active to a seperate image?

I would like to do something similar to what was posted here... 我想做类似于这里发布的内容......

Make Twitter Bootstrap navbar link active 使Twitter Bootstrap导航栏链接处于活动状态

Except instead of an item on the navbar becoming bolded, I would like it to use another image when active. 除了导航栏上的项目变为粗体外,我希望它在活动时使用另一个图像。 From this... 由此...

之前

to this... 对...

后

In the example link you posted, all they're doing is adding a CSS .active class to the active link. 在您发布的示例链接中,他们所做的只是在活动链接中添加CSS .active类。 If you do the same and have the active class being added to the correct element, you can do something in the css like, 如果你这样做并将活动类添加到正确的元素,你可以在css中做一些事情,比如

.active{
    background: url('path/to/image.jpg') no-repeat;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM