一个图片列表有5张小图片,鼠标移上去,如果对应的小图片里又大图的话,那么这张大图就小图片的中间向两边拉开显示,且铺满覆盖住这5张小图片,鼠标离开后,又会收缩回小图片里面,怎么实现?求这种效果,谢谢大神了。

解决方案 »

  1.   

    <!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>无标题文档</title>
    <style type="text/css">
    img{
    width:40px;
    height:40px;
    }
    div{
    width:240px;
    height:40px;
    }
    </style>
    <script type="text/javascript">
    function init(){
    var imgs=document.images;
    for(var i=0;i<imgs.length;i++){
    imgs[i].onmouseover=function(){
    var img=new Image();
    img.src=this.src;
    var p=this.parentNode;
    img.style.width='240px';
    img.style.height='40px';
    img.style.position='absolute';
    img.style.left='0px';
    p.appendChild(img);
    img.onmouseout=function(){
    p.removeChild(img);
    }
    }
    }
    }
    window.onload=init;
    </script>
    </head><body>
    <div>
    <img src="a.jpg" />
    <img src="biggerl.jpg" />
    <img src="border.png" />
    <img src="building.jpg" />
    <img src="close.png" />
    </div>
    </body>
    </html>
    不是很明白你的意思
      

  2.   

    http://jsbin.com/uqacup/110/edit
    就是一个图片列表,有一种是上下滑动显示的,有一种是垂直居中Ul上下拉开显示的,怎么实现的?
    <!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>无标题文档</title>
    <style>
    ul,li{
    list-style:none;
    padding:0;
    margin:0;
    }
    #ul1{
    width:1000px;
    height:300px;
    overflow:hidden;
    margin:10px auto;
    position:relative;
    }
    #ul1 li{
    width:190px;
    height:300px;
    float:left;
    margin-right:10px;
    }
    .sbox{
    width:190px;
    height:300px;
    overflow:hidden;
    position:relative;
    }
    .sma{
    height:600px;
    overflow:hidden;
    color:#fff;
    position:absolute;
    top:0;
    }
    .a1{
    background:#ff6600;
    width:190px;
    height:300px;
    overflow:hidden;
    }
    .a2{
    background:#377f03;
    width:190px;
    height:300px;
    overflow:hidden;
    }
    .bigBox{
    height:0px;
    width:1000px;
    background:#990000;
    position:absolute;
    z-index:2;
    top:0;
    left:0;
    overflow:hidden;
    }
    .bigBox img{
    width:1000px;
    height:300px;
    }
    </style>
    <script>
    //class
    function getByClass(oParent, sClass)
    {
    var aEle=oParent.getElementsByTagName('*');
    var aResult=[];
    var re=new RegExp('\\b'+sClass+'\\b', 'i');
    var i=0;
    for(i=0;i<aEle.length;i++)
    {
    if(re.test(aEle[i].className))
    {
    aResult.push(aEle[i]);
    }
    }
    return aResult;
    }
    //getstyle
    function getStyle(obj, attr)
    {
    if(obj.currentStyle)
    {
    return obj.currentStyle[attr];
    }
    else
    {
    return getComputedStyle(obj, false)[attr];
    }
    }
    //move
    function startMove(obj, json, fn)
    {
    clearInterval(obj.timer);
    obj.timer=setInterval(function (){
    var bStop=true;
    for(var attr in json)
    {
    var iCur=0;if(attr=='opacity')
    {
    iCur=parseInt(parseFloat(getStyle(obj, attr))*100);
    }
    else
    {
    iCur=parseInt(getStyle(obj, attr));
    }var iSpeed=(json[attr]-iCur)/8;
    iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);if(iCur!=json[attr])
    {
    bStop=false;
    }if(attr=='opacity')
    {
    obj.style.filter='alpha(opacity:'+(iCur+iSpeed)+')';
    obj.style.opacity=(iCur+iSpeed)/100;
    }
    else
    {
    obj.style[attr]=iCur+iSpeed+'px';
    }
    }
    if(bStop)
    {
    clearInterval(obj.timer);if(fn)
    {
    fn();
    }
    }
    }, 30)
    }window.onload=function(){
    var aUl=document.getElementById('ul1');
    var aLi=aUl.getElementsByTagName('li');
    var sImg=getByClass(aUl,'sma');
    var i=0;
    var iNow=0;
    var iNow2=0;
    for(i=0;i<aLi.length;i++){
    aLi[i].index=i;
    aLi[i].onmouseover=function(){
    var aImg=this.getElementsByTagName('img');
    var bImg=getByClass(this,'bigBox');
    iNow=this.index;

    if(aImg.length>1){
    if(bImg){
    startMove(bImg[iNow],{height:300});
    }
    }else{
    startMove(sImg[iNow],{top:-aLi[0].offsetHeight})
    }
    };
    aLi[i].onmouseout=function(){
    var aImg=this.getElementsByTagName('img');
    var bImg=getByClass(this,'bigBox');
    iNow=this.index;

    if(aImg.length>1){
    startMove(bImg[iNow],{height:0});
    }else{
    startMove(sImg[iNow],{top:0})
    }
    };
    };
    };
    </script>
    </head><body>
    <ul id="ul1">
    <li>
    <div class="sbox">
    <div class="sma">
    <div class="a1">正常显示层</div>
    <div class="a2">上下切换显示层</div>
    </div>
    </div>
    </li>
    <li>
    <div class="a1">正常显示层</div>
    <div class="bigBox">从ul的中间上下拉开显示层</div>
    </li>
    <li>
    <div class="sbox">
    <div class="sma">
    <div class="a1">正常显示层</div>
    <div class="a2">上下切换显示层</div>
    </div>
    </div>
    </li>
    <li>
    <div class="sbox">
    <div class="sma">
    <div class="a1">正常显示层</div>
    <div class="a2">上下切换显示层</div>
    </div>
    </div>
    </li>
    <li>
    <div class="a1">正常显示层</div>
    <div class="bigBox">从ul的中间上下拉开显示层</div>
    </li>
    </ul>
    </body>
    </html>