Colors
How do I make an colors?
Enter an hex or rgb value and hit + to save it to the page. What is a colors? How do you make a colors? This script and codes were developed by Barbara Laird on 16 January 2023, Monday.
Colors - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Colors</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
<div id="wrap"> <input type="text" id="hex" placeholder="hex"> <input type="text" id="rgb" placeholder="rgb"> <div style="text-align:center;width:100%"><a href="javascript:void(0);" id="save" title="Click to Save" >+</a></div> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Colors - Script Codes CSS Codes
* { margin: 0; padding: 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
}
html, body { height: 100%;
}
body, input { font: 15px/22px "Poiret One", sans-serif; text-transform: uppercase; color: #222; background: #fff;
}
a { text-decoration: none; color: #222;
} a:hover { color: #111; }
a.disabled { color:#aaa; cursor: default;
}
#save { font-size: 46px; font-weight: 800; line-height: 46px; margin-left:auto; margin-right:auto;
}
input { display: block; border: none; border-bottom: 1px dotted #666; background: transparent; font-size: 36px; font-weight: 800; line-height: 46px; width: 300px; -webkit-border-radius: 0px; border-radius: 0px;
} input:focus { outline: none; }
#hex { margin-bottom: 16px;
}
#wrap { width: 340px; height: 196px; position: absolute; top: 50%; left: 50%; margin: -98px -150px; padding: 20px;
}
h1 { font-size: 60px; line-height: 70px; width: 100%; height: 70px; text-align: center; position: absolute; top: 50%; left: 0; margin-top: -35px;
}
.saveColor { width:150px; height:100%; z-index:99; float: left; font-size: 18px; font-weight: 800; text-align: center;
}
.saveColor a { font-size: 36px;
}
.inner { padding: 40px 0;
}
::-webkit-input-placeholder { color: #222; text-shadow: none;
}
:-moz-placeholder { color: #222; text-shadow: none;
}
::-moz-placeholder { color: #222; text-shadow: none;
}
:-ms-input-placeholder { color: #222; text-shadow: none;
}
Colors - Script Codes JS Codes
// Inspired by http://hex.colorrrs.com
$(function () { var $hex = $('#hex'); var $rgb = $('#rgb'); var $body = $('body'); var $save = $('#save'); var $wrap = $('#wrap'); function calcWidth(bodyWidth, bodyHeight, chip, heightDiv) { var width = bodyWidth / chip; if (width < 160) { heightDiv++; return calcWidth(bodyWidth, bodyHeight, Math.ceil(chip /2), heightDiv); } else { return {width: width, height:bodyHeight/heightDiv}; } } $save.bind('click', function () { var id = 'save' + Math.ceil(Math.random() * 1000), html = '<div class="saveColor" id="' + id + '"></div>', value = $hex.val(), hex = '#' + (value + '').replace(/#/, ''), rgb = $rgb.val(), threshold, $allChips, $div, size; if ($save.hasClass('disabled')) return false; $body.prepend(html); $div = $('#' + id); $div.css('background', hex); $div.append('<p class="inner">' +hex + '<br/>' + rgb + '<br/>' + '<div style="text-align:center;width:100%""><a href="javascript:void(0);" onclick="jQuery(this).parent().parent().remove();return false;">-</a></div></p>'); rgb = rgb.slice(4, -1).split(','); threshold = Math.round(((parseInt(rgb[0]) * 299) + (parseInt(rgb[1]) * 587) + (parseInt(rgb[2]) * 114)) / 1000); if (threshold > 125) { $div.css('color', 'black'); $div.find('a').css('color', 'black'); } else { $div.css('color', 'white'); $div.find('a').css('color', 'white'); } $allChips = $('.saveColor'); size = calcWidth($body.width(), $body.height(), $allChips.length, 1); $allChips.width(size.width); $allChips.height(size.height); return false; }); $hex.bind('blur keyup', function () { var rgb = [], fail = false, value = $hex.val(), hex = (value + '').replace(/#/, ''); if (value.length === 1 && value !== '#') { $hex.val(value); } if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; for (var i = 0; i < 6; i += 2) { rgb.push(parseInt(hex.substr(i, 2), 16)); fail = fail || rgb[rgb.length - 1].toString() === 'NaN'; } $rgb.val(fail ? '' : 'rgb(' + rgb.join(',') + ')'); if (!fail) { $wrap.css('background', '#' + value); $save.removeClass('disabled'); } else { $save.addClass('disabled'); } }); $rgb.bind('blur keyup', function () { var value = this.value, rgb, hex = '', component, i; try { if (value && value.indexOf('rgb(') === 0 && value[value.length - 1] === ')') { rgb = value.slice(4, -1).split(','); if (rgb.length === 3) { for (i = 0; i < 3; i++) { if (rgb[i] <= 0xFF) { component = parseInt(rgb[i], 10); if (isNaN(component)) { throw new SyntaxError(); } component = component.toString(16); if (component.length === 1) { component = '0' + component; } hex += component; } else { throw new RangeError(); } } $hex.val('#' + hex); $body.css('background', '#' + hex); $save.removeClass('disabled'); } else { $save.addClass('disabled'); throw new SyntaxError(); } } } catch (e) { $hex.val(''); } });
});
$(document).ready(function () { $('#hex').focus(); $('#save').addClass('disabled');
});
Developer | Barbara Laird |
Username | bhlaird |
Uploaded | January 16, 2023 |
Rating | 4 |
Size | 3,569 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Flexbox Dice | 2,149 Kb |
A Pen by Barbara Laird | 1,795 Kb |
Bullseye | 2,019 Kb |
Sketch heart | 2,202 Kb |
Terry Hover Effect from Codrops | 2,941 Kb |
Smile More | 3,720 Kb |
Windows | 2,686 Kb |
Coming Soon | 3,075 Kb |
Atom | 1,932 Kb |
Einstien Quotes | 5,220 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CubeTronic | Jurbank | 3,716 Kb |
Segments mouse following | Nosir | 2,909 Kb |
Fun form with currentColor | Bnthor | 2,713 Kb |
Nav Test -- cats 1 | Payls | 4,735 Kb |
Html5-canvas-snow-effect | MariamMassadeh | 2,609 Kb |
Import shader in three.js | Khangeldy | 2,636 Kb |
Twitch Live Channels | Inkblotty | 4,956 Kb |
JavaScript constructors | Simboonlong | 2,415 Kb |
Material design - button rainbow circle | Kunukn | 3,652 Kb |
A Pen by aleen42 | Aleen42 | 11,473 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!