PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
Lightbox "klebt" immer oben
Beitrag
<blockquote data-quote="pusher23" data-source="post: 2245779" data-attributes="member: 354333"><p>Hallo,</p><p></p><p>ich habe folgendes Problem:</p><p>Ich nutze Lightbox 2.04 für eine Bildergalerie mit sehr vielen Fotos.</p><p>Nun sind es auf manchen Seiten so viele Fotos dass man nach unten scrollen muss.</p><p></p><p>Scrollt man weit nach unten und öffnet ein Foto, so klebt die Lightbox am oberen Rand der Website und ist somit nur mehr teilweise bis garnicht mehr sichtbar.</p><p>Man muss also extra wieder nach oben scrollen um sich das Bild ansehen zu können, was nicht gerade userfreundlich ist.</p><p></p><p>Hab mit der zugehörigen CSS-Datei und dem Script ein paar diletantische Versuche gewagt, leider ohne Erfolg.</p><p>Wäre toll wenn mir jemand helfen könnte, ich poste mal den Code:</p><p></p><p>HTML-Page:</p><p>[CODE]</p><p><a rel="lightbox[popupbox]" href="../Fotos/001.jpg"><img style="border: 0px; padding: 0px;" src="../Fotos/k/001.jpg" border="0" alt="" /></a></p><p>[/CODE]CSS:</p><p>[CODE]</p><p>#lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;}</p><p>#lightbox img{ width: auto; height: auto;}</p><p>#lightbox a img{ border: none; }</p><p></p><p>#outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; }</p><p>#imageContainer{ padding: 10px; }</p><p></p><p>#loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; }</p><p>#hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; }</p><p>#imageContainer>#hoverNav{ left: 0;}</p><p>#hoverNav a{ outline: none;}</p><p></p><p>#prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; }</p><p>#prevLink { left: 0; float: left;}</p><p>#nextLink { right: 0; float: right;}</p><p>#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; }</p><p>#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; }</p><p></p><p>#imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; }</p><p></p><p>#imageData{ padding:0 10px; color: #666; }</p><p>#imageData #imageDetails{ width: 70%; float: left; text-align: left; } </p><p>#imageData #caption{ font-weight: bold; }</p><p>#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; } </p><p>#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;} </p><p></p><p>#overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; }</p><p>[/CODE]JS:</p><p>[CODE]</p><p>// -----------------------------------------------------------------------------------</p><p>//</p><p>// Lightbox v2.04</p><p>// by Lokesh Dhakar - http://www.lokeshdhakar.com</p><p>// Last Modification: 2/9/08</p><p>//</p><p>// For more information, visit:</p><p>// http://lokeshdhakar.com/projects/lightbox2/</p><p>//</p><p>// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/</p><p>// - Free for use in both personal and commercial projects</p><p>// - Attribution requires leaving author name, author link, and the license info intact.</p><p>//</p><p>// Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets.</p><p>// Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous.</p><p>//</p><p>// -----------------------------------------------------------------------------------</p><p>/*</p><p></p><p> Table of Contents</p><p> -----------------</p><p> Configuration</p><p></p><p> Lightbox Class Declaration</p><p> - initialize()</p><p> - updateImageList()</p><p> - start()</p><p> - changeImage()</p><p> - resizeImageContainer()</p><p> - showImage()</p><p> - updateDetails()</p><p> - updateNav()</p><p> - enableKeyboardNav()</p><p> - disableKeyboardNav()</p><p> - keyboardAction()</p><p> - preloadNeighborImages()</p><p> - end()</p><p></p><p> Function Calls</p><p> - document.observe()</p><p></p><p>*/</p><p>// -----------------------------------------------------------------------------------</p><p></p><p>//</p><p>// Configurationl</p><p>//</p><p>LightboxOptions = Object.extend({</p><p> fileLoadingImage: '/fg/images/loading.gif',</p><p> fileBottomNavCloseImage: '/fg/images/closelabel.gif',</p><p></p><p> overlayOpacity: 0.8, // controls transparency of shadow overlay</p><p></p><p> animate: true, // toggles resizing animations</p><p> resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest)</p><p></p><p> borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable</p><p></p><p> // When grouping images this is used to write: Image # of #.</p><p> // Change it for non-english localization</p><p> labelImage: "Image",</p><p> labelOf: "of"</p><p>}, window.LightboxOptions || {});</p><p></p><p>// -----------------------------------------------------------------------------------</p><p></p><p>var Lightbox = Class.create();</p><p></p><p>Lightbox.prototype = {</p><p> imageArray: [],</p><p> activeImage: undefined,</p><p></p><p> // initialize()</p><p> // Constructor runs on completion of the DOM loading. Calls updateImageList and then</p><p> // the function inserts html at the bottom of the page which is used to display the shadow</p><p> // overlay and the image container.</p><p> //</p><p> initialize: function() {</p><p></p><p> this.updateImageList();</p><p></p><p> this.keyboardAction = this.keyboardAction.bindAsEventListener(this);</p><p></p><p> if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10;</p><p> if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1;</p><p></p><p> this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0;</p><p> this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration</p><p></p><p> // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.</p><p> // If animations are turned off, it will be hidden as to prevent a flicker of a</p><p> // white 250 by 250 box.</p><p> var size = (LightboxOptions.animate ? 250 : 1) + 'px';</p><p></p><p></p><p> // Code inserts html at the bottom of the page that looks similar to this:</p><p> //</p><p> // <div id="overlay"></div></p><p> // <div id="lightbox"></p><p> // <div id="outerImageContainer"></p><p> // <div id="imageContainer"></p><p> // <img id="lightboxImage"></p><p> // <div style="" id="hoverNav"></p><p> // <a href="#" id="prevLink"></a></p><p> // <a href="#" id="nextLink"></a></p><p> // </div></p><p> // <div id="loading"></p><p> // <a href="#" id="loadingLink"></p><p> // <img src="http://www.psd-tutorials.de/forum/images/loading.gif"></p><p> // </a></p><p> // </div></p><p> // </div></p><p> // </div></p><p> // <div id="imageDataContainer"></p><p> // <div id="imageData"></p><p> // <div id="imageDetails"></p><p> // <span id="caption"></span></p><p> // <span id="numberDisplay"></span></p><p> // </div></p><p> // <div id="bottomNav"></p><p> // <a href="#" id="bottomNavClose"></p><p> // <img src="http://www.psd-tutorials.de/forum/images/close.gif"></p><p> // </a></p><p> // </div></p><p> // </div></p><p> // </div></p><p> // </div></p><p></p><p></p><p> var objBody = $$('body')[0];</p><p></p><p> objBody.appendChild(Builder.node('div',{id:'overlay'}));</p><p></p><p> objBody.appendChild(Builder.node('div',{id:'lightbox'}, [</p><p> Builder.node('div',{id:'outerImageContainer'},</p><p> Builder.node('div',{id:'imageContainer'}, [</p><p> Builder.node('img',{id:'lightboxImage'}),</p><p> Builder.node('div',{id:'hoverNav'}, [</p><p> Builder.node('a',{id:'prevLink', href: '#' }),</p><p> Builder.node('a',{id:'nextLink', href: '#' })</p><p> ]),</p><p> Builder.node('div',{id:'loading'},</p><p> Builder.node('a',{id:'loadingLink', href: '#' },</p><p> Builder.node('img', {src: LightboxOptions.fileLoadingImage})</p><p> )</p><p> )</p><p> ])</p><p> ),</p><p> Builder.node('div', {id:'imageDataContainer'},</p><p> Builder.node('div',{id:'imageData'}, [</p><p> Builder.node('div',{id:'imageDetails'}, [</p><p> Builder.node('span',{id:'caption'}),</p><p> Builder.node('span',{id:'numberDisplay'})</p><p> ]),</p><p> Builder.node('div',{id:'bottomNav'},</p><p> Builder.node('a',{id:'bottomNavClose', href: '#' },</p><p> Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage })</p><p> )</p><p> )</p><p> ])</p><p> )</p><p> ]));</p><p></p><p></p><p> $('overlay').hide().observe('click', (function() { this.end(); }).bind(this));</p><p> $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this));</p><p> $('outerImageContainer').setStyle({ width: size, height: size });</p><p> $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this));</p><p> $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this));</p><p> $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this));</p><p> $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this));</p><p></p><p> var th = this;</p><p> (function(){</p><p> var ids =</p><p> 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' +</p><p> 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose';</p><p> $w(ids).each(function(id){ th[id] = $(id); });</p><p> }).defer();</p><p> },</p><p></p><p> //</p><p> // updateImageList()</p><p> // Loops through anchor tags looking for 'lightbox' references and applies onclick</p><p> // events to appropriate links. You can rerun after dynamically adding images w/ajax.</p><p> //</p><p> updateImageList: function() {</p><p> this.updateImageList = Prototype.emptyFunction;</p><p></p><p> document.observe('click', (function(event){</p><p> var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]');</p><p> if (target) {</p><p> event.stop();</p><p> this.start(target);</p><p> }</p><p> }).bind(this));</p><p> },</p><p></p><p> //</p><p> // start()</p><p> // Display overlay and lightbox. If image is part of a set, add siblings to imageArray.</p><p> //</p><p> start: function(imageLink) {</p><p></p><p> $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });</p><p></p><p> // stretch overlay to fill page and fade in</p><p> var arrayPageSize = this.getPageSize();</p><p> $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });</p><p></p><p> new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity });</p><p></p><p> this.imageArray = [];</p><p> var imageNum = 0;</p><p></p><p> if ((imageLink.rel == 'lightbox')){</p><p> // if image is NOT part of a set, add single image to imageArray</p><p> this.imageArray.push([imageLink.href, imageLink.title]);</p><p> } else {</p><p> // if image is part of a set..</p><p> this.imageArray =</p><p> $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]').</p><p> collect(function(anchor){ return [anchor.href, anchor.title]; }).</p><p> uniq();</p><p></p><p> while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; }</p><p> }</p><p></p><p> // calculate top and left offset for the lightbox</p><p> var arrayPageScroll = document.viewport.getScrollOffsets();</p><p> var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);</p><p> var lightboxLeft = arrayPageScroll[0];</p><p> this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();</p><p></p><p> this.changeImage(imageNum);</p><p> },</p><p></p><p> //</p><p> // changeImage()</p><p> // Hide most elements and preload image in preparation for resizing image container.</p><p> //</p><p> changeImage: function(imageNum) {</p><p></p><p> this.activeImage = imageNum; // update global var</p><p></p><p> // hide elements during transition</p><p> if (LightboxOptions.animate) this.loading.show();</p><p> this.lightboxImage.hide();</p><p> this.hoverNav.hide();</p><p> this.prevLink.hide();</p><p> this.nextLink.hide();</p><p> // HACK: Opera9 does not currently support scriptaculous opacity and appear fx</p><p> this.imageDataContainer.setStyle({opacity: .0001});</p><p> this.numberDisplay.hide();</p><p></p><p> var imgPreloader = new Image();</p><p></p><p> // once image is preloaded, resize image container</p><p></p><p></p><p> imgPreloader.onload = (function(){</p><p> this.lightboxImage.src = this.imageArray[this.activeImage][0];</p><p> this.resizeImageContainer(imgPreloader.width, imgPreloader.height);</p><p> }).bind(this);</p><p> imgPreloader.src = this.imageArray[this.activeImage][0];</p><p> },</p><p></p><p> //</p><p> // resizeImageContainer()</p><p> //</p><p> resizeImageContainer: function(imgWidth, imgHeight) {</p><p></p><p> // get current width and height</p><p> var widthCurrent = this.outerImageContainer.getWidth();</p><p> var heightCurrent = this.outerImageContainer.getHeight();</p><p></p><p> // get new width and height</p><p> var widthNew = (imgWidth + LightboxOptions.borderSize * 2);</p><p> var heightNew = (imgHeight + LightboxOptions.borderSize * 2);</p><p></p><p> // scalars based on change from old to new</p><p> var xScale = (widthNew / widthCurrent) * 100;</p><p> var yScale = (heightNew / heightCurrent) * 100;</p><p></p><p> // calculate size difference between new and old image, and resize if necessary</p><p> var wDiff = widthCurrent - widthNew;</p><p> var hDiff = heightCurrent - heightNew;</p><p></p><p> if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'});</p><p> if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration});</p><p></p><p> // if new and old image are same size and no scaling transition is necessary,</p><p> // do a quick pause to prevent image flicker.</p><p> var timeout = 0;</p><p> if ((hDiff == 0) && (wDiff == 0)){</p><p> timeout = 100;</p><p> if (Prototype.Browser.IE) timeout = 250;</p><p> }</p><p></p><p> (function(){</p><p> this.prevLink.setStyle({ height: imgHeight + 'px' });</p><p> this.nextLink.setStyle({ height: imgHeight + 'px' });</p><p> this.imageDataContainer.setStyle({ width: widthNew + 'px' });</p><p></p><p> this.showImage();</p><p> }).bind(this).delay(timeout / 1000);</p><p> },</p><p></p><p> //</p><p> // showImage()</p><p> // Display image and begin preloading neighbors.</p><p> //</p><p> showImage: function(){</p><p> this.loading.hide();</p><p> new Effect.Appear(this.lightboxImage, {</p><p> duration: this.resizeDuration,</p><p> queue: 'end',</p><p> afterFinish: (function(){ this.updateDetails(); }).bind(this)</p><p> });</p><p> this.preloadNeighborImages();</p><p> },</p><p></p><p> //</p><p> // updateDetails()</p><p> // Display caption, image number, and bottom nav.</p><p> //</p><p> updateDetails: function() {</p><p></p><p> // if caption is not null</p><p> if (this.imageArray[this.activeImage][1] != ""){</p><p> this.caption.update(this.imageArray[this.activeImage][1]).show();</p><p> }</p><p></p><p> // if image is part of set display 'Image x of x'</p><p> if (this.imageArray.length > 1){</p><p> this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show();</p><p> }</p><p></p><p> new Effect.Parallel(</p><p> [</p><p> new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }),</p><p> new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration })</p><p> ],</p><p> {</p><p> duration: this.resizeDuration,</p><p> afterFinish: (function() {</p><p> // update overlay size and update nav</p><p> var arrayPageSize = this.getPageSize();</p><p> this.overlay.setStyle({ height: arrayPageSize[1] + 'px' });</p><p> this.updateNav();</p><p> }).bind(this)</p><p> }</p><p> );</p><p> },</p><p></p><p> //</p><p> // updateNav()</p><p> // Display appropriate previous and next hover navigation.</p><p> //</p><p> updateNav: function() {</p><p></p><p> this.hoverNav.show();</p><p></p><p> // if not first image in set, display prev image button</p><p> if (this.activeImage > 0) this.prevLink.show();</p><p></p><p> // if not last image in set, display next image button</p><p> if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show();</p><p></p><p> this.enableKeyboardNav();</p><p> },</p><p></p><p> //</p><p> // enableKeyboardNav()</p><p> //</p><p> enableKeyboardNav: function() {</p><p> document.observe('keydown', this.keyboardAction);</p><p> },</p><p></p><p> //</p><p> // disableKeyboardNav()</p><p> //</p><p> disableKeyboardNav: function() {</p><p> document.stopObserving('keydown', this.keyboardAction);</p><p> },</p><p></p><p> //</p><p> // keyboardAction()</p><p> //</p><p> keyboardAction: function(event) {</p><p> var keycode = event.keyCode;</p><p></p><p> var escapeKey;</p><p> if (event.DOM_VK_ESCAPE) { // mozilla</p><p> escapeKey = event.DOM_VK_ESCAPE;</p><p> } else { // ie</p><p> escapeKey = 27;</p><p> }</p><p></p><p> var key = String.fromCharCode(keycode).toLowerCase();</p><p></p><p> if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox</p><p> this.end();</p><p> } else if ((key == 'p') || (keycode == 37)){ // display previous image</p><p> if (this.activeImage != 0){</p><p> this.disableKeyboardNav();</p><p> this.changeImage(this.activeImage - 1);</p><p> }</p><p> } else if ((key == 'n') || (keycode == 39)){ // display next image</p><p> if (this.activeImage != (this.imageArray.length - 1)){</p><p> this.disableKeyboardNav();</p><p> this.changeImage(this.activeImage + 1);</p><p> }</p><p> }</p><p> },</p><p></p><p> //</p><p> // preloadNeighborImages()</p><p> // Preload previous and next images.</p><p> //</p><p> preloadNeighborImages: function(){</p><p> var preloadNextImage, preloadPrevImage;</p><p> if (this.imageArray.length > this.activeImage + 1){</p><p> preloadNextImage = new Image();</p><p> preloadNextImage.src = this.imageArray[this.activeImage + 1][0];</p><p> }</p><p> if (this.activeImage > 0){</p><p> preloadPrevImage = new Image();</p><p> preloadPrevImage.src = this.imageArray[this.activeImage - 1][0];</p><p> }</p><p></p><p> },</p><p></p><p> //</p><p> // end()</p><p> //</p><p> end: function() {</p><p> this.disableKeyboardNav();</p><p> this.lightbox.hide();</p><p> new Effect.Fade(this.overlay, { duration: this.overlayDuration });</p><p> $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });</p><p> },</p><p></p><p> //</p><p> // getPageSize()</p><p> //</p><p> getPageSize: function() {</p><p></p><p> var xScroll, yScroll;</p><p></p><p> if (window.innerHeight && window.scrollMaxY) {</p><p> xScroll = window.innerWidth + window.scrollMaxX;</p><p> yScroll = window.innerHeight + window.scrollMaxY;</p><p> } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac</p><p> xScroll = document.body.scrollWidth;</p><p> yScroll = document.body.scrollHeight;</p><p> } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari</p><p> xScroll = document.body.offsetWidth;</p><p> yScroll = document.body.offsetHeight;</p><p> }</p><p></p><p> var windowWidth, windowHeight;</p><p></p><p> if (self.innerHeight) { // all except Explorer</p><p> if(document.documentElement.clientWidth){</p><p> windowWidth = document.documentElement.clientWidth;</p><p> } else {</p><p> windowWidth = self.innerWidth;</p><p> }</p><p> windowHeight = self.innerHeight;</p><p> } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode</p><p> windowWidth = document.documentElement.clientWidth;</p><p> windowHeight = document.documentElement.clientHeight;</p><p> } else if (document.body) { // other Explorers</p><p> windowWidth = document.body.clientWidth;</p><p> windowHeight = document.body.clientHeight;</p><p> }</p><p></p><p> // for small pages with total height less then height of the viewport</p><p> if(yScroll < windowHeight){</p><p> pageHeight = windowHeight;</p><p> } else {</p><p> pageHeight = yScroll;</p><p> }</p><p></p><p> // for small pages with total width less then width of the viewport</p><p> if(xScroll < windowWidth){</p><p> pageWidth = xScroll;</p><p> } else {</p><p> pageWidth = windowWidth;</p><p> }</p><p></p><p> return [pageWidth,pageHeight];</p><p> }</p><p>}</p><p></p><p>document.observe('dom:loaded', function () { new Lightbox(); });</p><p>[/CODE]Vielen Dank und</p><p>schöne Grüße</p><p></p><p>EDIT: Ich habe das Thema bewusst im "PHP and andere Scriptsprachen"-Bereich erstellt, da ich denke es handelt sich um ein Scriptproblem und ich hier somit am Besten aufgehoben bin. Sollte ich dennoch irren, bitte verschieben.</p></blockquote><p></p>
[QUOTE="pusher23, post: 2245779, member: 354333"] Hallo, ich habe folgendes Problem: Ich nutze Lightbox 2.04 für eine Bildergalerie mit sehr vielen Fotos. Nun sind es auf manchen Seiten so viele Fotos dass man nach unten scrollen muss. Scrollt man weit nach unten und öffnet ein Foto, so klebt die Lightbox am oberen Rand der Website und ist somit nur mehr teilweise bis garnicht mehr sichtbar. Man muss also extra wieder nach oben scrollen um sich das Bild ansehen zu können, was nicht gerade userfreundlich ist. Hab mit der zugehörigen CSS-Datei und dem Script ein paar diletantische Versuche gewagt, leider ohne Erfolg. Wäre toll wenn mir jemand helfen könnte, ich poste mal den Code: HTML-Page: [CODE] <a rel="lightbox[popupbox]" href="../Fotos/001.jpg"><img style="border: 0px; padding: 0px;" src="../Fotos/k/001.jpg" border="0" alt="" /></a> [/CODE]CSS: [CODE] #lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;} #lightbox img{ width: auto; height: auto;} #lightbox a img{ border: none; } #outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; } #imageContainer{ padding: 10px; } #loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; } #hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; } #imageContainer>#hoverNav{ left: 0;} #hoverNav a{ outline: none;} #prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; } #prevLink { left: 0; float: left;} #nextLink { right: 0; float: right;} #prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; } #nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; } #imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; } #imageData{ padding:0 10px; color: #666; } #imageData #imageDetails{ width: 70%; float: left; text-align: left; } #imageData #caption{ font-weight: bold; } #imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; } #imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;} #overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; } [/CODE]JS: [CODE] // ----------------------------------------------------------------------------------- // // Lightbox v2.04 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 2/9/08 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: '/fg/images/loading.gif', fileBottomNavCloseImage: '/fg/images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="http://www.psd-tutorials.de/forum/images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="http://www.psd-tutorials.de/forum/images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.rel == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { // if caption is not null if (this.imageArray[this.activeImage][1] != ""){ this.caption.update(this.imageArray[this.activeImage][1]).show(); } // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); }); [/CODE]Vielen Dank und schöne Grüße EDIT: Ich habe das Thema bewusst im "PHP and andere Scriptsprachen"-Bereich erstellt, da ich denke es handelt sich um ein Scriptproblem und ich hier somit am Besten aufgehoben bin. Sollte ich dennoch irren, bitte verschieben. [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 5, ▼ = 2 und ■ = 7, was ist ▲ × ▼ + ■?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
Lightbox "klebt" immer oben
Oben