VW Calculator

by Torwan

HTML

<div class="field pixel">
		<label for="pixel">Enter Your Pixel Unit</label>
		<input id="pixel" name="pixel"  type="number" min="0" class="m-pixel" placeholder="enter your pixel unit"/>		 
	</div>
	<div class="field pixel">
		<label for="vpwidth">Enter Your viewport width</label>
		<input id="vpwidth" name="vpwidth"  type="number" min="0" class="m-vpwidth" placeholder="enter your viewport width"/>		 
	</div>
	<div class="button">
		<a href="javascript:void(0);">Click to get vw unit</a>
	</div>
	<div class="output">
		<label></label>
	</div>

CSS

body {
	margin: 0 auto;
	padding: 10% 0;
	font-style: normal;
	font-family: "news-gothic-std", sans-serif;
	font-weight: 400;
	color: #fff;
	max-width: 80%;
	/* Fallback (could use .jpg/.png alternatively) */
	background-color: #DBC1B3;
	/* SVG fallback for IE 9 (could be data URI, or could use filter) */
	background-image: url(fallback-gradient.svg);
	/* Safari 4, Chrome 1-9, iOS 3.2-4.3, Android 2.1-3.0 */
	background-image: -webkit-gradient(linear, left top, right top, from(#DBC1B3 ), to(#7f7f7f));
	/* Safari 5.1, iOS 5.0-6.1, Chrome 10-25, Android 4.0-4.3 */
	background-image: -webkit-linear-gradient(left, #DBC1B3 , #7f7f7f);
	/* Firefox 3.6 - 15 */
	background-image: -moz-linear-gradient(left, #DBC1B3 , #7f7f7f);
	/* Opera 11.1 - 12 */
	background-image: -o-linear-gradient(left, #DBC1B3 , #7f7f7f);
	/* Opera 15+, Chrome 25+, IE 10+, Firefox 16+, Safari 6.1+, iOS 7+, Android 4.4+ */
	background-image: linear-gradient(to right, #DBC1B3 , #7f7f7f);
}
.field {
	font-size: 0;
	margin-bottom: 3vw;
}
.field label {
	width: 50%;
	display: inline-block;
	vertical-align: middle;
	text-align: left;
	text-transform: uppercase;
	font-size: 3vw;
	padding-bottom: 0px;
}
input, select {
	-webkit-appearance: none;
	-moz-appearance: none;
	border: 0px solid #3f424c;
	width: 50%;
	margin-bottom: 0;
	height: 7vw;
	float: none;
	clear: both;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	display: inline-block;
	vertical-align: middle;
	letter-spacing: 0.6vw;
	line-height: normal;
	border-radius: 0px;
	background: #FFF;
	color: #7c7c7c;
	font-size: 2vw;
	font-family: "news-gothic-std", sans-serif;
	text-indent: 0;
	text-transform: lowercase;
	padding: 0 2.6vw 0 2.6vw;
	outline: none;
}
input::-webkit-input-placeholder {
	color: #7c7c7c;
}

input:-moz-placeholder {/* Firefox 18- */
	color: #7c7c7c;
	opacity: 1;
}

input::-moz-placeholder {/* Firefox 19+ */
	color: #7c7c7c;
	opacity: 1;
}

input:-ms-input-placeholder {
	color:...

JavaScript

jQuery(document).ready(function() {
	jQuery('.button a').click(function() {
		var pxValue = jQuery('#pixel').val();
		var vpwidth = jQuery('#vpwidth').val();
		var vwValue = parseFloat(pxValue / vpwidth) * 100;
		vwValue = vwValue + "vw";
		jQuery('.output label').text(vwValue);
		jQuery('.output').show();
	});

});