Skip to content

Instantly share code, notes, and snippets.

@ideabrian
Created May 4, 2017 15:30
Show Gist options
  • Save ideabrian/5d3c39ade946c1ffb2146265f3faa2ed to your computer and use it in GitHub Desktop.
Save ideabrian/5d3c39ade946c1ffb2146265f3faa2ed to your computer and use it in GitHub Desktop.
Background Color Picker
<div id="hex">
<input type="color" id="color" value="#49bc58" onchange="getColor()" />
<h1 id="output">CHOOSE A COLOR</h1>
</div>
function getColor() {
var color = $("#color").val();
$("body").css("background", color);
$("#output").text(color);
$("#output").css("color", color);
}
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
body {
display: flex;
justify-content: center;
background: #49bc58;
align-items: center;
height: 100vh;
}
#hex {
border-radius: 10px;
width: auto;
height: auto;
background: white;
color: #555;
text-align: center;
padding: 20px;
}
#color {
outline: none;
border: 0;
transition: all 0.5s ease;
width: 100px;
height: 100px;
&:hover {
transform: scale(1.1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment