javascript可生成自定义组合颜色的调色板工具

所属分类: 网页特效-实用工具    2023-12-13 11:45:06

javascript可生成自定义组合颜色的调色板工具 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

javascript可生成自定义组合颜色的调色板工具(共3个文件)

    • index.html

使用方法

var color = document.querySelectorAll(".color")
var coloralt = document.querySelectorAll(".color-alt")
var container = document.querySelector(".container")

function start(event) {
    function randomColorGen() {
        
        hexColor = "#" + (Math.random() * 0xFFFFFF << 0).toString(16);
        hexColorRe = hexColor.substring(0, 1) + hexColor.substring(1, 7).split("").reverse().join("");

        //red ssettings
        if (event === 'red') {
            hexColor = hexColor.substring(0, 1) + "00" + hexColor.substring(3, 5) + hexColor.substring(5);
            hexColorRe = hexColorRe.substring(0, 1) + "00" + hexColorRe.substring(3, 5) + hexColorRe.substring(5);
        }
        if (event === 'redlight') {
            hexColor = hexColor.substring(0, 1) + "ff" + hexColor.substring(3, 5) + hexColor.substring(5);
            hexColorRe = hexColorRe.substring(0, 1) + "ff" + hexColorRe.substring(3, 5) + hexColorRe.substring(5);
        }
        if (event === 'reddark') {
            hexColor = hexColor.substring(0, 1) + hexColor.substring(1, 3) + "00" + "00";
            hexColorRe = hexColorRe.substring(0, 1) + hexColorRe.substring(1, 3) + "00" + "00";
        }
        //----------------------------

        //green settings
        if (event === 'green') {
            hexColor = hexColor.substring(0, 1) + hexColor.substring(1, 3) + "00" + hexColor.substring(5);
            hexColorRe = hexColorRe.substring(0, 1) + hexColorRe.substring(1, 3) + "00" + hexColorRe.substring(5);
        }
        if (event === 'greenlight') {
            hexColor = hexColor.substring(0, 1) + hexColor.substring(1, 3) + "ff" + hexColor.substring(5);
            hexColorRe = hexColorRe.substring(0, 1) + hexColorRe.substring(1, 3) + "ff" + hexColorRe.substring(5);
        }
        if (event === 'greendark') {
            hexColor = hexColor.substring(0, 1) + "00" + hexColor.substring(3, 5) + "00";
            hexColorRe = hexColorRe.substring(0, 1) + "00" + hexColorRe.substring(3, 5) + "00";
        }
        //----------------------------

        //blue settings
        if (event === 'blue') {
            hexColor = hexColor.substring(0, 1) + hexColor.substring(1, 3) + hexColor.substring(3, 5) + "00";
            hexColorRe = hexColorRe.substring(0, 1) + hexColorRe.substring(1, 3) + hexColorRe.substring(3, 5) + "00";
        }
        if (event === 'bluelight') {
            hexColor = hexColor.substring(0, 1) + hexColor.substring(1, 3) + hexColor.substring(3, 5) + "ff";
            hexColorRe = hexColorRe.substring(0, 1) + hexColorRe.substring(1, 3) + hexColorRe.substring(3, 5) + "ff";
        }
        if (event === 'bluedark') {
            hexColor = hexColor.substring(0, 1) + "00" + "00" + hexColor.substring(5);
            hexColorRe = hexColorRe.substring(0, 1) + "00" + "00" + hexColorRe.substring(5);
        }
        //----------------------------


        container.style.background = `linear-gradient(to bottom, ${hexColor.substring(0, 7) + "50"},${hexColorRe.substring(0, 7) + "50"})`;
    }

       

    for (let i = 0; i < color.length; i++) {
        randomColorGen()
        color[0].style.backgroundColor = hexColor;
        color[1].style.backgroundColor = hexColorRe;
        coloralt[0].innerHTML = hexColor;
        coloralt[1].innerHTML = hexColorRe;

    }
    for (let i = 0; i < color.length; i++) {
        randomColorGen()
        color[2].style.backgroundColor = hexColor;
        color[3].style.backgroundColor = hexColorRe;
        coloralt[2].innerHTML = hexColor;
        coloralt[3].innerHTML = hexColorRe;

    }
}

for (let i = 0; i < color.length; i++) {
    color[i].addEventListener("click", ()=>{
        navigator.clipboard.writeText(coloralt[i].textContent)
        coloralt[i].classList.add("copys")
        setTimeout(() => {
            coloralt[i].classList.remove("copys")
        }, 500);
    })   
}


start()

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

javascript可生成自定义组合颜色的调色板工具

这是一款生成随机的颜色组合工具,可自定义不显示指定颜色。还提供了一种快速生成颜色功能,鼠标悬停可复制十六进制颜色代码。
  实用工具
 248  

jquery按原子序数排序的标准元素周期表

使用jQuery、JSON和CSSGrid创建一个按原子序数排序的标准元素周期表(118个元素),鼠标悬停即可显示详细信息。
  实用工具
 172  

jquery网页html表格数据转可下载EXCEL插件

一款html网页table表格数据到excel转换器,可基于HTML表生成一个可下载的Excel XSL文件。
  实用工具
 202  

jquery简易版在线记事本工具插件

一款简单的在线记事本应用程序,可记录笔记或书写短文等,可保存下来供日后使用。
  实用工具
 209  

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论