简体   繁体   中英

How to detect the prominent color of a webpage?

I am wondering if there is a way to detect the prominent color of a webpage? I mean mainly the background color of the page using javascript and html5.

Please note that I am mainly considering two scenarios: 1. a page with a background color and 2. a page with a background image.

I will more more than happy if any has some good ideas on this question.

使用jquery查找body标签的background-color值。

$("body").css("background-color")

For all elements on the site:

$("*").each(function(e){
     console.log($(this).css('backgroundColor'));
});

does the trick.

Just sort the results properly.

HTH

Gekkstah

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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