cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1 id="hd">color code changer</h1>
<div>
	<div>
		<h2>HEX</h2>
		#<input id="hex" type="text" maxlength="6" value="" />
	</div>

	<div>
		<div class="arrow"></div>
	</div>

	<div>
		<h2>RGB</h2>
		<input id="rgb" type="text" value="" />
	</div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Roboto:100,400);

//  convert size
@function size($n) {
	@return (100vmin / 360) * $n;
}

html,
body,
input {
	font-family: 'Roboto', sans-serif;
	font-size: size(24);
	font-weight: 100;
	line-height: 1.5;
}

h1 {
	font-size: 1rem;
	text-align: center;
	
	color: #ccc;
}

body > div {
	display: flex;
	padding: 1rem;
	
	div {
		flex-grow: 2;
		width: 40%;
		margin: 1rem 0;
		font-size: 2rem;
		text-align: center;
		white-space: nowrap;

		&:nth-child(2) {
			position: relative;
			flex-grow: 2;
			width: 10%;
			.arrow {
				position: absolute; 
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				width:  1.5em;
				height: .05em;
				margin: auto;
				background: #000;

				&::before,
				&::after {
					content: '';

					position: absolute; 
					top: 0;
					left: .1rem;
					right: .1rem;
					bottom: 0;
					width:  .5em;
					height: .5em;
					margin: auto;

					border: solid #000;
					border-width: .05em .05em 0 0;

					transform-origin: center center;
				}
				&::before {
					right: auto;
					transform: rotate(225deg);
				}
				&::after {
					left: auto;
					transform: rotate(45deg);
				}
			}
		}

		h2 {
			font-size: 1rem;
		}

		input {
			width: 6em;
			padding: 0 .5rem;
			font-size: 1em;
			text-align: center;
		}
	}


}


            
          
!
            
              (function(window, document, undefined){
	var _self = this;
	
    // RGB
    _self.get_rgb = function(color) {
      return {
        r: parseInt(color.substring(0,2), 16),
        g: parseInt(color.substring(2,4), 16),
        b: parseInt(color.substring(4,6), 16)
      };
    };

    // HEX
    _self.get_hex = function(rgb) {
		var two = function(v) {
			return ('0' + v).slice(-2);
		}
      return two(rgb.r.toString(16)) + two(rgb.g.toString(16)) + two(rgb.b.toString(16));
    };
	
	//  hex disits
    _self.get_sixDigits = function(color) {
      var c = {
        r: color.substring(0,1),
        g: color.substring(1,2),
        b: color.substring(2,3)
      };
      return c.r + c.r + c.g + c.g + c.b + c.b;
    };
	
  // DOMContentLoaded
  _self.initialize = function(){
	  
	  var hex = document.getElementById('hex');
	  var rgb = document.getElementById('rgb');
	  var hd = document.getElementById('hd');
	
	  // hex -> rgb
	  hex.addEventListener('change', function(e){
		  var v = e.currentTarget.value;
		  if(v.length) {
			  if(v.length === 3) {
				 v = _self.get_sixDigits(v);
			  }
			  if(v.length === 6) {
				  var color = _self.get_rgb(v);
				  rgb.value = color.r + ',' + color.g + ',' + color.b;
				  
				  hd.style.backgroundColor = 'rgb(' + color.r + ',' + color.g + ',' + color.b + ')';
			  }
		  }
	  }, false);
	  
	  // rgb -> hex
	  rgb.addEventListener('change', function(e){
		  var v = e.currentTarget.value.split(',');
		  if(v.length) {
			  var color = _self.get_hex({
				  r: +v[0],
				  g: +v[1],
				  b: +v[2]
			  });
			  hex.value = color;
			  hd.style.backgroundColor = '#' + hex.value;
		  }
	  }, false);
	  
  }; // DOMContentLoaded
  document.addEventListener('DOMContentLoaded', _self.initialize, false);

})(this, this.document);
            
          
!
999px
Loading ..................

Console