我们能否通过点击某个按钮并在上面添加JavaScript来使导航颜色动态化?

huangapple go评论68阅读模式
英文:

Can we make a nav color dynamic with some button to click and add js on it?

问题

嗨,我是编程世界的新手,我做了一个小导航栏,像这样,我想添加一个按钮,当点击它时,它应该改变颜色。
在此输入图像描述

我已经制作了导航栏并添加了所有图标,但现在我不知道如何为它添加功能。

英文:

Hi I am new at the world of programming I make a small nav bar like this and I want to add a button when it click it should change the color.
enter image description here

I made the nav bar and brought all icons but now I don't know hot to add a functionality on it.

答案1

得分: 1

以下是翻译好的部分:

有一些使用伪类和选择器来改变颜色的方法。

<selector>:hover {
/* 
当鼠标移动到链接上时,你可以在这里做一些变化。
*/
}

<selector>:focus {
/* 
这意味着当鼠标按住鼠标左键并保持按下时,可以在这里进行一些变化。
*/
}

<selector>:visited {
/* 
这可能是你希望在用户访问链接后执行的效果。
*/
}

还有更多的伪类可以使用,请查看以下链接。
https://developer.mozilla.org/en-US/docs/Web/CSS/:visited

英文:

There are few way to change color with pseudo-classes with selectors.

<selector>:hover {
/* 
when the mouse move over to the link then you can do something change in here.
*/
}

<selector>:focus {
/* 
which means that when the mouse hold the mouse left click keep press do something change in here.
*/
}

<selector>:visited {
/* 
this might you want effect when user visited the link css to do. 
*/
}

There has more pseudo-classes can do, please check the link.
https://developer.mozilla.org/en-US/docs/Web/CSS/:visited

huangapple
  • 本文由 发表于 2023年7月11日 13:26:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658911.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定