我编写了一个声音板。当鼠标悬停在按钮上并点击它时,会播放特殊的声音。当鼠标悬停在按钮上时,每个按钮的图片都会改变以显示按下状态。我的问题是,我不知道如何在第5个按钮(中心位置的按钮)被点击后,将图片动画移动到屏幕左侧超过500像素的右侧。该图像只是Facebook图标,作为占位符,以下是代码!
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$('#button5').click(function() {
$('#cat').animate({
right: '+=500'
}
, 5000 );
});
});
$(document).ready(function ()
{
var audioon = false;
$('.button').click(function ()
{
var audioObj = $(this).find("audio");
var audioTag = audioObj[0];
audioTag.volume = 0.90;
if (audioon)
{
audioTag.pause();
audioon = false;
} else {
audioTag.play();
audioon = true;
}
});
});
</script>
<title>Square 205 Soundboard</title>
</head>
<body>
<div class="container">
<div="buttons">
<div id="cat">
<img src="http://www.avca.org/includes/media/images/facebook-icon-small.jpg">
</div>
<div class="row">
<div id="button1" class="button">
<audio preload="none">
<source src="sounds/DBZ.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button2" class="button">
<audio preload="none">
<source src="sounds/GD.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button3" class="button">
<audio preload="none">
<source src="sounds/LeanneBoops.mp3" type="audio/mpeg">
</audio>
</div>
</div>
<div class="row">
<div id="button4" class="button">
<audio preload="none">
<source src="sounds/MakeMeMoney.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button5" class="button">
<audio preload="none">
<source src="sounds/Meow.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button6" class="button">
<audio preload="none">
<source src="sounds/Yeah.mp3" type="audio/mpeg">
</audio>
</div>
</div>
<div class="row">
<div id="button7" class="button">
<audio preload="none">
<source src="sounds/Dang.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button8" class="button">
<audio preload="none">
<source src="sounds/Benny.mp3" type="audio/mpeg">
</audio>
</div>
<div id="button9" class="button">
<audio preload="none">
<source src="sound.mp3" type="audio/mpeg">
</audio>
</div>
</div>
<div class="row">
<div id="button10" class="button">
<audio preload="none">
<source src="sound.mp3" type="audio/mpeg">
</audio>
</div>
</div>
</div>
</div>
</body>
</html>
**CSS**
body {
background-color: white;
}
audio {
display: none;
}
.container {
width:960px;
margin:0 auto;
background:url(buttons/frame.png) no-repeat center top;
padding-bottom: 110px;
padding-top: 20px;
}
.row {
width:100%;
text-align:center;
}
.button:hover {
cursor:pointer;
}
.row div{
display: inline-block;
margin-right: 2px;
}
.button {
height:143px;
width:143px;
}
#button1 {
background:url(buttons/button1.png) no-repeat;
}
#button1:hover
{
background:url(buttons/button1p.png) no-repeat;
}
#button2 {
background:url(buttons/button2.png) no-repeat;
}
#button2:hover
{
background:url(buttons/button2p.png) no-repeat;
}
#button3 {
background:url(buttons/button3.png) no-repeat;
}
#button3:hover
{
background:url(buttons/button3p.png) no-repeat;
}
#button4 {
background:url(buttons/button4.png) no-repeat;
}
#button4:hover
{
background:url(buttons/button4p.png) no-repeat;
}
#button5 {
background:url(buttons/button5.png) no-repeat;
}
#button5:hover
{
background:url(buttons/button5p.png) no-repeat;
}
#button6 {
background:url(buttons/button6.png) no-repeat;
}
#button6:hover
{
background:url(buttons/button6p.png) no-repeat;
}
#button7 {
background:url(buttons/button7.png) no-repeat;
}
#button7:hover
{
background:url(buttons/button7p.png) no-repeat;
}
#button8 {
background:url(buttons/button8.png) no-repeat;
}
#button8:hover
{
background:url(buttons/button8p.png) no-repeat;
}
#button9 {
background:url(buttons/button9.png) no-repeat;
}
#button9:hover
{
background:url(buttons/button9p.png) no-repeat;
}
#button10 {
background:url(buttons/button1.png) no-repeat;
}
#button10:hover
{
background:url(buttons/button1p.png) no-repeat;