-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.html
79 lines (70 loc) · 2.28 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!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 -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- Unit.js -->
<script src="Length.min.js"></script>
<!-- test -->
<script>
var units = ['10%', '96px', '25.4mm', '2.54cm', '1in', '72pt', '6pc', '25.4mozmm', '6rem', '10vh', '10vw', '10vm', '10vmin', '10vmax', '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>