鼠标移上去自动放大

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Google的放大</TITLE>
<SCRIPT LANGUAGE="JavaScript" src=" http://www.veryhuo.com/uploads/common/js/jquery-1.3.2.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
$(function(){
var t;
$(".show1").mouseout(
function(){
clearTimeout(t);
var img=$(this).find("img");
var src=img.attr("src");
img.attr("src",img.attr("src2")).attr("src2",src)
.css({top:0,left:0,width:125,height:125})
.end().unbind("mousemove").bind("mousemove",m1);
}).mousemove(m1);
function m1(e){
var that=this;
clearTimeout(t);
//$("#info").html($("#info").html()+t+"<br/>");
t=setTimeout(function(){
$(that).unbind("mousemove");
var thisOffset=$(that).offset();
var left=-((e.pageX-thisOffset.left)*(313/125-1));
var top=-((e.pageY-thisOffset.top)*(313/125-1));
//$("#info").html($("#info").html()+e.pageY+"|"+$(that).offset().top+"|"+left+"|"+top+"<br/>");
$(that).find("img").animate({height:"313px",width:"313px",top:top,left:left},{duration:500,complete:function(){
var img=$(this);
var src=img.attr("src");
img.attr("src",img.attr("src2")).attr("src2",src).parent().mousemove(m2);
}});
},200);
}
function m2(e){
var b=312/125;
var thisOffset1=$(this).offset();
var left1=-((e.pageX-thisOffset1.left)*(313/125-1));
var top1=-((e.pageY-thisOffset1.top)*(313/125-1));
//$("#info")[0].innerHTML+="b:"+b+" |left:"+((left1))+"|"+"top:"+((top1))+"---l:"+l+"|t:"+t+"<br>";
$(this).find("img").css({top:top1,left:left1});
}
});
//-->
</SCRIPT>
<style type="text/css">
.show1{
width:125;
height:125;
border:1px solid blue;
cursor:pointer;
overflow:hidden;
position:relative;
background-color:gray;
}
.img1{
width:125;
height:125;
position:absolute;
}
</style>
</HEAD>
<BODY>
<div class="show1" οnclick=""><img class="img1" src=" http://www.veryhuo.com/uploads/allimg/090108/1108250.jpg"></img></div>
<div id="info"></div>
</BODY>
</HTML>
好的,那么以下是实现你所需功能的代码。 HTML代码: ```html <div class="notes-container"> <div class="note"> <h3 class="note-title"></h3> <div class="note-content"></div> </div> <!-- 其他11个便签 --> </div> ``` CSS代码: ```css /* 便签容器样式 */ .notes-container { display: flex; flex-wrap: wrap; justify-content: space-between; max-width: 800px; margin: 0 auto; } /* 便签样式 */ .note { position: relative; width: calc(33.3% - 10px); height: 200px; margin-bottom: 20px; background-color: #fff; border: 1px solid #ccc; box-shadow: 0px 0px 5px #ccc; transition: transform 0.3s ease-out; } /* 鼠标移上去放大过渡效果 */ .note:hover { transform: scale(1.1); } /* 便签标题样式 */ .note-title { position: absolute; top: 10px; left: 10px; font-size: 20px; } /* 便签内容样式 */ .note-content { position: absolute; top: 50px; left: 10px; font-size: 16px; } /* 通过nth-child选择器实现对便签的背景色和字体颜色控制 */ .note:nth-child(2n) { background-color: #f5f5f5; } .note:nth-child(3n) { background-color: #f0f0f0; } .note:nth-child(4n) { background-color: #e5e5e5; } /* 便签旋转效果 */ .note:nth-child(odd) { transform: rotate(-3deg); } .note:nth-child(even) { transform: rotate(3deg); } ``` JavaScript代码: ```javascript // 获取便签容器 const notesContainer = document.querySelector('.notes-container'); // 从本地存储中读取数据,假设数据格式为JSON数组 const notesData = JSON.parse(localStorage.getItem('notes')); // 遍历数据,创建便签并添加到容器中 notesData.forEach(note => { const noteEl = document.createElement('div'); noteEl.classList.add('note'); const titleEl = document.createElement('h3'); titleEl.classList.add('note-title'); titleEl.textContent = note.title; const contentEl = document.createElement('div'); contentEl.classList.add('note-content'); contentEl.textContent = note.content; noteEl.appendChild(titleEl); noteEl.appendChild(contentEl); notesContainer.appendChild(noteEl); }); ``` 这份代码实现了你所需要的功能,包括: 1. 从本地存储中读取数据,并根据数据动态生成便签。 2. 通过nth-child选择器实现对便签的背景色和字体颜色控制。 3. 便签具有旋转效果和阴影效果,鼠标移上去时具有放大过渡效果。 如果你有任何问题或者需要进一步的帮助,请告诉我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值