Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2a3ccec97c
Fetching contributors…

Cannot retrieve contributors at this time

78 lines (70 sloc) 2.338 kb
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
html, body {
font-size: 100%;
}
.wrapper {
__width: 960px;
position: relative;
*height: 1px;
}
.box {
position: relative;
background-color: yellow;
width: 160px;
height: 30px;
border: 2px solid red;
padding: 8px;
margin-bottom: 10px;
zoom: 1;
}
</style>
</head>
<body>
<div class="wrapper">
</div>
<div id="test">
</div>
<strong id="strong">hello</strong>
<em id="em">hello</em>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!-- Unit.js -->
<script src="Length.js"></script>
<!-- test -->
<script>
var units = ['10%', '96px', '25.4mm', '2.54cm', '1in', '72pt', '6pc', '25.4mozmm', '6rem', '10vh', '10vw', '10vm', '6em', '13.4ex', '12ch'],
tmp,
i = units.length,
len,
tmpl = '<div class="box" style="margin-left: {{css}}">{{label}}: {{value}}</div>',
vars = ['{{css}}', '{{label}}', '{{value}}'],
$el, $wrapper = $('.wrapper');
while (i--) {
$el = $(template(tmpl, vars, [units[i], 'Margin Left', units[i]])).appendTo($wrapper);
len = Length.toPx($el[0], units[i], 'marginLeft');
$(template(tmpl, vars, [len + 'px', 'Converted', units[i]])).appendTo($wrapper);
console.log(units[i], '=>', len + 'px');
}
// super simple tempate
function template(subject, substr, newSubStr) {
var i = substr.length, str = subject;
while (i--) {
str = str.replace(substr[i], newSubStr[i]);
}
return str;
}
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.