<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="jquery-1.7.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("#flt").hover(function(){
$("#flt").animate({right:"0px"},300);
},function(){
$("#flt").animate({right:"-150px"},300);
});
});
</script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="flt">
<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" bgcolor="#990000"> </td>
<td bgcolor="#FFC8C8"> </td>
</tr>
</table>
</div>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="1000" bgcolor="#0066CC"> </td>
</tr>
</table>
</body>
</html>
style.css
就这么几行
#flt
{
width:200px;
height:50px;
position:fixed;
right:-150px;
top:150px;
}
这就实现了,fixed定位是相对浏览器的一种绝对定位,然后用jquery来定义在那个层上的触发事件就可以改变其right值实现浮动了。
转载于:https://blog.51cto.com/net5x/1559223