Monday, 18 October 2010

Cross browser rotating divs using jQuery

Below, I have used the jQuery plugin called rotate at http://code.google.com/p/jquery-rotate/
Normally, I like to refer to these online, but for some reason, it didn't work, so you'll have to download it as I have done in the example below. Another unfortunately, is that I had to create a wrapper for IE. The code is still quite small.

See demo.

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset="UTF-8">
<title>Rotate text</title>
<style>
body
{
font-family:Sans-serif;
}
#wrapper
{
margin:0 auto;
width:300px;
height:300px;
}
#container
{

width:200px;
height:200px;
background:#FF0000;
color:#FFFFFF;
border:2px solid #000000;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
 google.load("jquery", "1");
 google.load("jqueryui", "1");
</script>
<script src="scripts/jquery.rotate.js"></script>
<script>
$(document).ready(function()
{
$('#container').css('rotate',6.1);
});
</script>
</head>
<body>
<br /><br />
<div id="wrapper">
<div id="container">
<h1>Hello World!</h1>
</div>
</div>
</body>
</HTML>

No comments:

Post a Comment