限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

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

jquery创建的html5在线绘图工具插件

一个简单易用的基于jQuery和HTML5 Canvas的绘画插件,可在自动生成的HTML5画布上实现简单的绘图功能。
  实用工具
 7279  0

jquery通过AJAX请求延迟执行函数插件

一款轻量级延迟执行函数插件,可通过AJAX动态请求自定义时间后要执行的函数。
  实用工具
 2253  0

jquery带动画特效的天气信息卡片

一款极简风格天气卡片,带有水位波动的动画效果,非常好看。
  实用工具
 9115  0

jquery自动获取当前客户端显示器参数信息插件

stage是一个简单的获取设备信息插件,用于检测和显示当前客户端显示器的参数信息,如大小、对角线长度、显示像素、每像素点数、方向等。
  实用工具
 5288  0

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

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