我想知道是否有办法在不使用fotoshop的情况下旋转图像,我想使用css或javascript
我正在寻找的结果是here
以下解决方案有效但我想旋转我的图像而没有悬停属性,如果我删除悬停在这里图像不旋转
<style>
#card img:hover {
transform: rotateY(360deg);
-webkit-transform: rotateY(180deg);
transition-duration: 1.5s;
-webkit-transition-duration:1s;
}
</style>
如果找到我想要的效果here
答案 0 :(得分:1)
img {
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
}
答案 1 :(得分:1)
使用CSS&#39; rotate
,rotateX
,rotateY
,rotateZ
。小例子:
img {
transform: inherit;
transition: all 0.3s;
width: 100px;
}
img:hover {
transform: rotateX(45deg)
rotateY(45deg)
rotateZ(45deg);
}
rotate
是2D变换方法,rotateX
,rotateY
,rotateZ
是3D变换方法。
答案 2 :(得分:0)
我认为你看起来像下面的代码,这是小提琴Link和Other Link 这可能对你有所帮助!!
<img class="image" src="https://www.arxan.com/wp-content/uploads/assets1/images/demo.png" alt="" width="120" height="120">
<style>
.image {
position: absolute;
top: 50%;
left: 50%;
width: 120px;
height: 120px;
margin:-60px 0 0 -60px;
-webkit-animation:spin 4s linear infinite;
-moz-animation:spin 4s linear infinite;
animation:spin 4s linear infinite;
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
</style>
答案 3 :(得分:0)
看看这堂课:
var ImgRotator = {
angle: parseInt(45),
image: {},
src: "",
canvasID: "",
intervalMS: parseInt(500),
jump: parseInt(5),
start_action: function (canvasID, imgSrc, interval, jumgAngle) {
ImgRotator.jump = jumgAngle;
ImgRotator.intervalMS = interval;
ImgRotator.canvasID = canvasID;
ImgRotator.src = imgSrc;
var image = new Image();
var canvas = document.getElementById(ImgRotator.canvasID);
image.onload = function () {
ImgRotator.image = image;
canvas.height = canvas.width = Math.sqrt(image.width * image.width + image.height * image.height);
window.setInterval(ImgRotator.keepRotating, ImgRotator.intervalMS);
//theApp.keepRotating();
};
image.src = ImgRotator.src;
},
keepRotating: function () {
ImgRotator.angle += ImgRotator.jump;
var canvas = document.getElementById(ImgRotator.canvasID);
var ctx = canvas.getContext("2d");
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(ImgRotator.angle * Math.PI / 180);
ctx.drawImage(ImgRotator.image, -ImgRotator.image.width / 2, -ImgRotator.image.height / 2);
ctx.restore();
}
}
用法:
ImgRotator.start_action(canvasID, image_url, intervalInMilliseconds, jumgAngle);
HTML(只提供要旋转图像的画布):
<canvas id="canva" width="350" height="350"></canvas>
答案 4 :(得分:0)
事实上使用CSS和jquery我们可以做得更好,我的意思是在负载上旋转整个身体
NODE_PATH=./src NODE_ENV=production PORT=3010 APIPORT=3012 /node/path/node bin/server.js >> /log/path/mydomain.log 2>&1