Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <style>
  9. /* Chrome, Safari, Edge, Opera */
  10. input::-webkit-outer-spin-button,
  11. input::-webkit-inner-spin-button {
  12. -webkit-appearance: none;
  13. margin: 0;
  14. }
  15.  
  16. /* Firefox */
  17. input[type=number] {
  18. -moz-appearance: textfield;
  19. }
  20. input[type="color"] {
  21. -webkit-appearance: none;
  22. border: none;
  23. width: 64px;
  24. height: 64px;
  25. }
  26. </style>
  27. <title>Document</title>
  28. <script>
  29. function sum() {
  30. let first = document.getElementById("c1").value.substring(1);
  31. let second = document.getElementById("c2").value.substring(1);
  32. document.getElementById("c3").value = "#"+addHexColor(first,second);
  33. }
  34. function addHexColor(c1, c2) {
  35. let first = parseInt(c1,16);
  36. let second = parseInt(c2,16);
  37. var hexStr = (first+second).toString(16);
  38. while (hexStr.length < 6) { hexStr = '0' + hexStr; } // Zero pad.
  39. return hexStr;
  40. }
  41. </script>
  42. </head>
  43.  
  44. <body>
  45. <input name="Color Picker" type="color" id="c1">
  46. +
  47. <input name="Color Picker" type="color" id="c2">
  48. =
  49. <input name="Color Picker" type="color" id="c3">
  50. <input type="button" onclick="sum()" value="calc">
  51. </body>
  52.  
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement