我試圖讓按鈕單擊後圖像旋轉,但我無法讓圖像旋轉。將css的動畫行放入圖像後:css中的活動id塊,我可以通過單擊活動鼠標來旋轉圖像,但這不是我的任務所要求的。爲什麼鼠標點擊後圖像不旋轉? (javascript + css)
HTML
<a id="button" onclick="rotate()">Go</a>
<img class="click" id="image" src="http://placehold.it/500x500">
<script type="text/javascript" src="script.js"></script>
</body>
的Javascript
function rotate(){
image.className = 'click';
}
CSS
#button {
font-family: "Verdana";
font-weight: inherit;
font-size: 3vmin;
line-height: 14vmin;
text-align: center;
display: block;
border: none;
background: white;
width: 15vmin;
height: 15vmin;
margin: 2vmin auto;
border-radius: 10vmin;
cursor: pointer;
color: black;
}
.click:active {
display: block;
background: transparent;
border: 0px solid transparent;
height: 50vh;
width: 50vh;
margin: 5vh auto 0;
transition: height 100ms, border-width 100ms, border-color 100ms;
animation: rotate;
animation-delay: 100ms;
animation-timing-function: reverse; animation-iteration-count: normal;
animation-duration: 1s;
animation-play-state: running;
animation-direction: reverse;
}
從哪裏'圖像'來? –
@DhavalMarthak click:active class最初是id,「#image:active」 – user50109
您還沒有設置圖像的旋轉角度。 –