How to get the background color of a specific part on an html page

I used Gradient to set the background color of my html body.

CSS

background: linear-gradient(to top,  #fb4080 10%,#ebb523 22%,#58d27c 40%,#2aff00 52%,#0fd2b7 65%,#6b6dff 80%,#ff05ea 100%);

Now the body is filled with several colors. Using javascript, how can I get rgb or hex code values ​​for a specific part of the page?

Example:

If I look at my page, I want to get the color of the upper part (the color inside the selected part is not accurate, but the values ​​next to it). So that I can assign / set this color code for another element on my page, for example, in the navigation bar, in the menu, etc.

enter image description here

Any suggestions?

+4
source share
1 answer
+1

All Articles