I know the question has been asked and I've searched and searched on here but a) i can't seem to figure out how to adapt what I've found and b) i have another small issue to go along with trying to add the next and previous buttons to my gallery-ish layout.
Here is the link to my page:
http://mymediaculture.com/_broadway_branding/index2.html
The second problem is that i'm using a pure css fadein/out transition effect, for my images but I can't find a way to make the first image of the gallery show when the page loads.
As you can see, I already have the next/previous links in place. Just don't know enough about js/jquery to make them work.
Any help would be greatly, greatly appreciated
html
<div id="top_mid_mid">
<a rel="nofollow" target="_blank" href="#">
<img id="mypicture" border="0" alt="portfolio" src="images/recent/recent1.jpg" />
</a>
<div id="prev"><a class="current" href="#" title="portfolio"><img alt="prev" src="images/prev.gif" id="prevlink" /></a></div>
<div id="next"><a class="current" href="#" title="portfolio"><img alt="next" src="images/next.gif" id="nextlink" /></a></div>
</div>
javascript
window.onload= recent_pic;
window.onload= toogle;
var mypix=new Array("images/recent/recent1.jpg","images/recent/recent2.jpg","images/recent/recent3.jpg","images/recent/recent4.jpg","images/recent/recent5.jpg");
var thispic = 0;
function recent_pic(){
document.getElementById("prevlink").onclick=processprev;
document.getElementById("nextlink").onclick=processnext;
document.getElementById(1).onclick = one;
document.getElementById(2).onclick = tow;
document.getElementById(3).onclick = three;
document.getElementById(4).onclick = four;
document.getElementById(5).onclick = five;
}
/******************for arrow ****************/
function processprev(){
if(thispic==0){
thispic=mypix.length;
}
thispic--;
document.getElementById("mypicture").src= mypix[thispic];
return false;
}
function processnext(){
thispic++;
if(thispic==mypix.length){
thispic=0;
}
document.getElementById("mypicture").src= mypix[thispic];
return false;
}
/******************for arrow end****************/
I have done complete bins for Image slide show with Previous and Next Buttons using jQuery. I think this Demo should be helpful for you, so the demo link as below.
Demo: http://codebins.com/bin/4ldqp8x
HTML:
<div class="topbar">
<ul id="navigation">
<li id="previous">
<a href="#tag">
Previous
</a>
</li>
<li class="active">
<a href="#">
1
</a>
</li>
<li>
<a href="#">
2
</a>
</li>
<li>
<a href="#">
3
</a>
</li>
<li>
<a href="#">
4
</a>
</li>
<li>
<a href="#">
5
</a>
</li>
<li>
<a href="#">
6
</a>
</li>
<li>
<a href="#">
7
</a>
</li>
<li>
<a href="#">
8
</a>
</li>
<li>
<a href="#">
9
</a>
</li>
<li>
<a href="#">
10
</a>
</li>
<li id="next">
<a href="#tag">
Next
</a>
</li>
</ul>
</div>
<div id="images">
<div class="slide">
<img src="http://thumbs.myopera.com/sz/colx/Mathilda%C2%B4s%20Wallpaper/albums/104123/Animal%20Friends.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://marowall.ru/Jivotnie/Grizuni/Kroliki1024/8/9.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://www.mejoresmascotas.com/wp-content/uploads/2009/02/perrito.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://data.whicdn.com/images/16010691/white_lion_large.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://koprol.zenfs.com/system/mugshots/0153/9924/index.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://cdn.cutestpaw.com/wp-content/uploads/2011/11/Cute-Squirrel-s.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://thumbs.myopera.com/sz/colx/adilsaadi/albums/5861552/horses.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://fundartspring2011.wikispaces.com/file/view/puppy_dogs_14.jpg/217071218/297x225/puppy_dogs_14.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://1.bp.blogspot.com/-zfT5EAh0Tz8/TbJVRf5wywI/AAAAAAAAAE4/TWWdSLhx9Io/s1600/ardilla.jpg" width="250" height="200" />
</div>
<div class="slide">
<img src="http://thumbs.myopera.com/sz/colx/skafridi/albums/6474892/animals-pictures-birds-bluebird.jpg" width="250" height="200" />
</div>
</div>
CSS:
.topbar{
position:fixed;
top:0;
left:0;
height:35px;
background:none repeat scroll 0 0 #B0832E;
border-shadow:1px 0 4px rgba(0, 0, 0, 0.4);
font-size:12px;
width:100%;
z-index:9999;
}
#navigation{
border: 1px solid red;
list-style: none outside none;
margin: 5px auto 0;
text-align: center;
width: 60%;
z-index: 3;
}
#navigation li{
display:inline-block;
background:none repeat scroll 0 0 rgba(255, 255, 255, 0.9);
box-shadow:1px 1px 2px rgba(0, 0, 0, 0.2);
border:1px solid white;
color:#444444;
font-size:12px;
text-transform:uppercase;
}
#navigation li a{
color:#444444;
text-decoration:none;
padding:2px 5px;
}
#navigation li.active a, #navigation li:hover a{
color:#fff;
background:#333;
text-decoration:underline;
}
#images{
text-align:center;
}
.slide{
padding:5px;
display:none;
position:absolute;
top:35;
margin-left:25%;
background:#2255a9;
}
jQuery:
$(function() {
//Show Current Active Image Slide On Document Ready
showSlide();
$("li", $("#navigation")).click(function() {
var activeIndex = $("li.active", $("#navigation")).index();
if (typeof $(this).attr('id') != "undefined") {
if ($(this).attr('id') == "previous" && activeIndex > 1) {
//set PREV Active Image
$("li", $("#navigation")).removeClass('active');
$("#navigation li:eq(" + (activeIndex - 1) + ")").attr('class', 'active');
} else if ($(this).attr('id') == "next" && activeIndex < ($("li", $("#navigation")).length - 2)) {
//set NEXT Active Image
$("li", $("#navigation")).removeClass('active');
$("#navigation li:eq(" + (activeIndex + 1) + ")").attr('class', 'active');
}
} else {
//set Active Image which slide no is clicked
$("li", $("#navigation")).removeClass('active');
$(this).attr('class', 'active');
}
//Check if Different Slide has been clicked or Move then only load..
if (activeIndex != $("li.active", $("#navigation")).index()) {
showSlide(); //Call to show active image
}
});
});
//Function to Show Current Active Image Slide
function showSlide() {
//Get Current Index of Active LI
var i = $("li.active", $("#navigation")).index();
//Check Range of Current Index
if (i > 0 && i < ($("li", $("#navigation")).length - 1)) {
//FadeOut all Images
$(".slide", $("#images")).fadeOut(1000);
//FadeIn Only Current Active Indexed Slided
$(".slide:eq(" + (i - 1) + ")", $("#images")).fadeIn(3000);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.