Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
	<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
</head>

<body onload="setPoint()">
	<a href="http://juliacodes.com"<div class="juliacodes">juliacodes.com</div></a>
	<div class="form-holder">
		<form onsubmit="return false;">
			<input type="text" value="196" placeholder="R" id="R">
			<input type="text" value="73" placeholder="G" id="G">
			<input type="text" value="0" placeholder="B" id="B"> <br />
			<button type="submit" onclick="setPoint()">Type your desired RGB and return</button>
		</form>
	</div>
	<div id="contain">
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
		<div class="block"></div>
	</div>	
</body>
              
            
!

CSS

              
                body{
font-family: 'Open Sans', sans-serif;	
}

*{
	padding: 0;
	margin: 0;
	background-color: #F5F6F8;
	text-decoration: none;
}

.form-holder { // centers the form
	width: 100%;
	height: auto;
	margin: 40px 0 0 0;
	positon: absolute;
}

button{ // return button resets colors form input
	background-color: white;
	border: none;
	font-size: 13px;
	margin-top: 20px;
}

form {
	position: relative;
	width: 300px;
	margin: auto;
	padding: 40px;
	background-color: #f9f9f9;
	box-shadow: 0px 0px 5px darkgray;
	border-top-left-radius: 30px;
	border-top-right-radius: 30px;
	outline: none;
}

input{
	color: black;
	display: inline-block;
	text-align: center;
	font-size: 50px;
	border: none;
	margin-right: 2px;
	background-color: white;
	border-radius: 20px;
	box-shadow: 0px 0px 10px #f0f0f0;
	width: 95px;
	height: 95px;
}

#contain{ // div for centering gradient blocks
	margin-left: 20vw;
	z-index: 22;
}

.block {
	width: 66.5%;
  padding: 25px 25px;
	background-color: #B13400;
	opacity: 1;
	font-size: 20px;
}

.block:hover{
	// set to important so it overrides javascript set color
	color: white !important;
	transition-duration: 1s !important;
}

#contain > :first-child{ // sets border radius for first child
	border-top-left-radius: 40px;
	border-top-right-radius: 40px;
}


.juliacodes{ // link to portfolio styling
	background-color: white;
	color: black;
	text-align: center;
	width: 120px;
	margin-left: 20px;
	padding: 5px;
}

textarea, select, input, button { //removes outline for all inputs
	outline: none; 
}

              
            
!

JS

              
                
var elements = document.body.getElementsByTagName('div'); // declares individual blocks by div
var msg = ''; // declares and sets the initial rgb display to 0;
var i; // declaring all variables
var r;
var g; 
var b;


//function that grabs user input. Run on page load to initialize placeholder rgb
function setPoint(){
	// sets vars to match user input value
	r = parseInt(document.getElementById("R").value);
	g = parseInt(document.getElementById("G").value);
	b = parseInt(document.getElementById("B").value);
	
	for (i = 0; i < elements.length; i++){ // loops for each gradient block
		// sets a delay for each element, gives the opacity load - in effect
		var delay = i/2; 
		contain.getElementsByTagName('div')[i].style.transitionDuration = delay + 's';

		contain.getElementsByTagName('div')[i].style.backgroundColor = getColor(); // sets background color to getColor Function
		contain.getElementsByTagName('div')[i].innerHTML = getColor(); // sets inner html to match rgb color displayed
		contain.getElementsByTagName('div')[i].style.color = getColor(); // sets the color of text to match background-color
		
		// adds a plsu 10 interval to initial color to create gradient
		r += 10;
		g += 10;
		b += 10;
	}
	
// function takes color vars and builds them into string
	function getColor(){
		var color = "rgb(" + r +","+ g +","+ b + ")";
		return color; // returns color that will be pulled for background
	}

return;
}
              
            
!
999px

Console