我想在下面的代碼中使用jquery動畫效果修復css位置。jquery動畫和CSS位置
我的綠色和橙色跨度在鼠標懸停控制上失控。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<style>
.box1{
width:40px;
height:13px;
float:left;
font-size:.6em; color:#fff; background:#99CC00;
font-family:Arial, Helvetica, sans-serif;
}
.box2{
width:40px;
height:auto;
float:left;
font-size:.6em; color:#fff; background:#FF6600;
font-family:Arial, Helvetica, sans-serif;
margin-top:1px;
opacity:.8;
filter: alpha(opacity=75);
}
</style>
<script>
$(function() {
$('span').hover(function() {
$(this).stop().css({ 'z-index': '999999', 'position': 'absolute', 'float': 'left'}).animate({ marginTop: '0px', marginLeft: '0px', top: '0', left: '0', width: '200px', height: '125px', padding: '0px' }, 700, 'swing');
}, function() {
$(this).stop().css({ 'z-index': '0', 'border': '0px' }).fadeIn('slow').animate({ marginTop: '0px', marginLeft: '0px', top: '0', left: '0', width: '40px', height: '13px', padding: '0px' }, 700, 'swing');
});
});
</script>
</head>
<body>
<table width="160" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40" height="40" valign="top" bgcolor="#e4e4e4">
<span class="box1">Hello ji</span>
<span class="box2">Sanket</span> </td>
<td width="40" height="40" valign="top" bgcolor="#CCCCCC"> </td>
<td width="40" height="40" valign="top" bgcolor="#999999"> </td>
<td width="40" height="40" valign="top" bgcolor="#666666"> </td>
</tr>
</table>
</body>
</html>
新來jquery,非常感謝。
僅供參考 - 提供問題代碼的工作示例去** *得多*比發佈代碼更進一步尋求協助。如果您的網頁未公開,請使用jsfiddle.net之類的工具發佈代碼的相關部分。我這次爲你做了一個小提琴(http://jsfiddle.net/sqCN5/1/)。 :) – Dutchie432 2011-05-25 12:48:01
你必須描述最後的樣子!這個問題有點不清楚。 – 2011-05-25 12:48:55
@ Dutchie432 - 好的dutchie。是的。我也喜歡製作JSfiddles,但對於SO和他的未來來說,在這個地方粘貼代碼是有好處的。或者有一天...如果他們關閉JSFiddle ....所以會保持**空!**)) – 2011-05-25 12:52:41