<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>图片旋转</title>
</head>
<body>
<div id="result-stub" class="well hidden">
<canvas id="canvas" width="345" height="345">
<p>你的浏览器不支持canvas元素</p>
</canvas>
</div>
<script>
window.onload=function() {
//1、 获取到画布对象以及画布的上下文对象
var canvas = document.getElementById('canvas')
var context = canvas.getContext('2d')
//2、 在画布上进行图片绘制
var img = new Image()
img.src = 'fist-pump-baby.jpg'//这里是绘制图片的路径
img.onload = function() {
context.drawImage(img, 0, 0)
}
//3、 设置画布旋转
context.rotate(0.2)//通过rotate方法以弧度为参数旋转图像
//在rotate中传入的参数为弧度。如果你对弧度不太了解,在HTML5中还提供了一个函数degreeToRadians()。它可以将度数转换为弧度。这里传入-15,即表示将图像向左旋转15度。如需把旋转的角度转换为弧度的公式为:( 度数*PI )/ 180。这两种传入弧度的方法你选择一种即可。
//context.rotate(degreesToRadians(-15))
}
</script>
<script src="jquery.js"></script>
</body>
</html>
这些都是有关于HTML5新特性的一些应用。给你推荐一个教程网站秒秒学,该网站上有关于HTML5新特性的讲解,可以去看看,希望对你有帮助。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>旋转</title>
<style>
* {margin:0padding:0border:0}
div {width:200pxheight:200pxmargin-left:100pxmargin-top:-100px}
img {width:200pxheight:200pxborder-radius:100pxanimation:myfirst 5s linear infinite-webkit-animation:myfirst 5s linear infiniteanimation-play-state:running-webkit-animation-play-state:running}
img:hover {animation-play-state:paused-webkit-animation-play-state:paused}
@keyframes myfirst {0% {transform:rotate(0deg)} 100% {transform:rotate(360deg)}}
@-webkit-keyframes myfirst {0% {transform:rotate(0deg)} 100% {transform:rotate(360deg)}}
</style>
</head>
<body>
<p style="margin-top:100px"></p>
<div><img src="163146_vN8g_574908.jpg"/><div>
</body>
</html>
需要的图片