简体   繁体   English

HTML相对于页面位置设置颜色?

[英]HTML set color relative to page position?

I've written a webpage with a nav-bar that has a transparent background on the top of the website, but gets a solid black color if scrolled down.我写了一个带有导航栏的网页,它在网站顶部有一个透明的背景,但如果向下滚动,它会变成纯黑色。

Now I want to add a dropdown menu.现在我想添加一个下拉菜单。 It would be nice if the dropdown-menu with the options has a transparent background on top, but otherwise a solid color, because otherwise it doesn't look good.如果带有选项的下拉菜单顶部有透明背景会很好,否则是纯色,否则看起来不太好。

I thought about it, but I have no clue how to do this.我想过,但我不知道如何做到这一点。

Can anyone help me?谁能帮我?

If you are using JS for changing the color of navbar on-scroll, then can't you piggyback off the same function to change CSS of hover too?如果您正在使用 JS 来更改滚动导航栏的颜色,那么您不能搭载相同的功能来更改悬停的 CSS 吗?

Sorry if this sounds stupid, But we (at least I) can't help out more than this without you posting the code.对不起,如果这听起来很愚蠢,但是如果没有您发布代码,我们(至少我)无法提供更多帮助。

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

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