Created
December 22, 2012 00:30
-
-
Save randallagordon/4356785 to your computer and use it in GitHub Desktop.
HTML5 Speedometer HUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Speedometer HUD</title> | |
<style type="text/css"> | |
.hud { | |
-webkit-transform: scaleX(-1) rotate(180deg); | |
-moz-transform: scaleX(-1) rotate(180deg); | |
-o-transform: scaleX(-1) rotate(180deg); | |
-ms-transform: scaleX(-1) rotate(180deg); | |
transform: scaleX(-1) rotate(180deg); | |
font-size: 100px; | |
} | |
body { | |
background: #000; | |
color: #fff; | |
font: 18px Helvetica, Arial, sans-serif; | |
margin: 0 auto; | |
width: 480px; | |
} | |
</style> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(function() { | |
navigator.geolocation.watchPosition(function(e){ | |
$("#speed").text(parseInt(e.coords.speed * 2.2369)); | |
}, function(e) {}, { enableHighAccuracy: true, maximumAge: 30000 }); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Speedometer HUD</h1> | |
<p>Using HTML5 Geolocation and CSS3 transforms to create a windshield-ready speedometer HUD.</p> | |
<p class="hud"><span id="speed">000</span> km/h</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment