【发布时间】:2020-12-05 14:10:15
【问题描述】:
在我网站的主页上,我有一个图像在您单击它之前应该是“损坏的”,我希望它从 23 度开始然后旋转到 0 并停留在那里。有任何想法吗?抱歉,如果这很难阅读,但这是我所拥有的:
相关 CSS:
<style>
.crossRotate {
-webkit-transition-duration: 1s;
-moz-transition-duration: 1s;
-o-transition-duration: 1s;
transition-duration: 1s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
transform: rotate(23deg);
}
/*.crossRotate:active {
transform: rotate(23deg);
-webkit-transform: rotate(23deg);
-ms-transform: rotate(23deg);
transform: rotate(23deg);
}*/
.crossRotate:active {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
font-size:50%;
}
nuggets{
max-width:20px;
max-height:15px;
font-size:20px;
}
</style>
相关 JS(在头部):
<script>
$( ".crossRotate" ).click(function() {
if ( $( this ).css( "transform" ) == 'none' ){
$(this).css("transform","rotate(0deg)");
} else {
$(this).css("transform","" );
}
});
</script>
</head>
相关 HTML:
<p><img class="crossRotate" src="images/example.jpg" alt="ExamplerAlt"></p>
记住:我希望它从 23 度变为 0 度并保持在 0 度
谢谢!
【问题讨论】:
-
我希望它在点击后保持为 0
-
如果您将其发布到 jsfiddle 或类似的沙箱。与您交流可行的解决方案会更容易。
标签: javascript html css rotation