2

我已经为一些杂志问题创建了一个图片库,我想把它设计成我所附图片中的东西,但我不确定你是否可以做我想要的,

我基本上想 jQuery 附加 div 1 和 3 中的图像并将其放在当前选择的 div(div 2)上的图像后面。

提前感谢您的帮助。

到目前为止,我还有一个用于代码的 js fiddle:http: //jsfiddle.net/huddds/5Z39B/1/

在此处输入图像描述

jQuery

 var issueTotal = 0;

$('#backIssue0').show();

$('.prevButton').hide();    

$('.nextButton').click(function(e) {
    e.preventDefault();

    issueTotal = issueTotal + 1;

    if(issueTotal > 0){
        $('.prevButton').show();
    }
    if(issueTotal < 4){
        $('.nextButton').show();
    }    
    if(issueTotal > 3){
        $('.nextButton').hide();
    }

    $("#backIssue" + issueTotal).show();
    if(issueTotal > 0) {
        $('#backIssue' + (issueTotal - 1)).hide();
    }

});


$('.prevButton').click(function(e) {
    e.preventDefault();

    issueTotal = issueTotal - 1;

    if(issueTotal > 1){
        $('.prevButton').show();
    }
    if(issueTotal < 1){
        $('.prevButton').hide();
    }
    if(issueTotal < 4){
        $('.nextButton').show();
    }    
    if(issueTotal > 3){
        $('.nextButton').hide();
    }

    $("#backIssue" + issueTotal).show();
    if(issueTotal > 0) {
        $('#backIssue' + (issueTotal - 1)).hide();
    }
});

HTML

 <div id="buttons">
     <a href="#" class="prevButton">PREVIOUS</a>
     <a href="#" class="nextButton">NEXT</a>
 </div>
 <div id=issueContainer>
 <div id="backIssue0">
     <img src="http://www.tuwidesign.com/tuwi/wp-content/uploads/2009/05/web_designer_magazine.jpg" width="100" alt="#" />
 </div>
 <div id="backIssue1">
     <img src="http://blogof.francescomugnai.com/wp-content/uploads/2008/07/cover_web_designer.jpg" width="100" alt="#" />
 </div>
 <div id="backIssue2">
     <img src="http://www.onerutter.com/wp-content/uploads/2011/10/WD189.jpg" width="100" alt="#" />
 </div>
 <div id="backIssue3">
     <img src="http://www.ukhumourweb.co.uk/web-design-201.jpg" width="100" alt="#" />
 </div>
 <div id="backIssue4">
     <img src="http://www.solidshops.com/blog/wp-content/uploads/web-designer-magazine1.jpg" width="100" alt="#" />
 </div>
 </div>

CSS

 #backIssue0{width:100px;display:none; float:left;}
 #backIssue1{width:100px;display:none;float:left;}
 #backIssue2{width:100px;display:none;float:left;}
 #backIssue3{width:100px;display:none;float:left;}
 #backIssue4{width:100px;display:none;float:left;}
 .nextButton{margin-left:50px;}
 .previousButton{}
 #issueContainer{width:100px;height:130px; overflow:hidden;}
 #buttons{clear:both;}​
               ​

​</p>

4

2 回答 2

1

http://jsfiddle.net/aEvhh/

这个怎么样?

html:

<div id="buttons">
    <a href="#" class="prevButton">PREVIOUS</a>
    <a href="#" class="nextButton">NEXT</a>
</div>
<div id=issueContainer>
<div id="backIssue0" class="issue">
    <img src="http://www.tuwidesign.com/tuwi/wp-content/uploads/2009/05/web_designer_magazine.jpg" width="100" alt="#" />
</div>
<div id="backIssue1" class="issue">
    <img src="http://blogof.francescomugnai.com/wp-content/uploads/2008/07/cover_web_designer.jpg" width="100" alt="#" />
</div>
<div id="backIssue2" class="issue">
    <img src="http://www.onerutter.com/wp-content/uploads/2011/10/WD189.jpg" width="100" alt="#" />
</div>
<div id="backIssue3" class="issue">
    <img src="http://www.ukhumourweb.co.uk/web-design-201.jpg" width="100" alt="#" />
</div>
<div id="backIssue4" class="issue">
    <img src="http://www.solidshops.com/blog/wp-content/uploads/web-designer-magazine1.jpg" width="100" alt="#" />
</div>
</div>

Javascript:

var issueTotal = 0;
function update_issues(){
    $('.issue').removeClass('comingup').hide();
    if(issueTotal >0){
        console.log('#backIssue' + (issueTotal -1));
     $('#backIssue' + (issueTotal -1)).addClass('comingup').show();   
    }
    $('#backIssue' + (issueTotal )).show();
    if(issueTotal <4){
     $('#backIssue' + (issueTotal +1)).addClass('comingup').show();  
    }
    if(issueTotal > 0){
        $('.prevButton').show();
    }
    if(issueTotal < 4){
        $('.nextButton').show();
    }    
}


    $('.nextButton').click(function(e) {
        e.preventDefault();

        issueTotal = issueTotal + 1;
        update_issues();
    });
    update_issues();

    $('.prevButton').click(function(e) {
        e.preventDefault();

        issueTotal = issueTotal - 1;
        update_issues();

    });

CSS:

.issue { width:100px;display:none;float:left;}
.nextButton{margin-left:50px;}
.previousButton{}
#issueContainer{width:300px;height:130px; overflow:hidden;}
.issue.comingup { opacity:0.4; filter:alpha(opacity=40); /* For IE8 and earlier */ }
#buttons{clear:both;}
于 2012-12-17T14:26:05.707 回答
0

由于您已经在使用 jQuery,您是否考虑过使用插件来完成这项工作?

Roundabout是一个 jQuery 插件,可以轻松地将无序列表和其他嵌套的 HTML 结构转换为有趣的、交互式的、类似转盘的区域。

它是开源的,并在 BSD 许可下发布,这意味着它可以在您的个人或商业项目中免费使用。

带图片的演示:

http://fredhq.com/projects/roundabout/demos/images

图片演示

带有 3D 效果的演示:

http://fredhq.com/projects/roundabout/demos/3d

3D 演示

您还可以使用环形交叉口形状使用新效果对其进行扩展

形状效果

于 2012-12-17T14:29:44.323 回答