Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightbox 2.51 - how to move close button and image number to the top?

I'm using Lightbox 2.51 and I can't find a solution to move lb-dataContainer with close button and current image number etc to the top

enter image description here

I only found solutions for the old versions.

Code can be found here: http://lokeshdhakar.com/projects/lightbox2/releases/lightbox2.51.zip

like image 400
user1327 Avatar asked Jan 29 '26 18:01

user1327


2 Answers

The solution is to change outer container with data container:

Lightbox.prototype.build = function() {
  var $lightbox,
    _this = this;

  $("<div>", {id: 'lightboxOverlay'}).after
    (
          $('<div/>', {id: 'lightbox'}
          ).append(

          $('<div/>', {
            "class": 'lb-dataContainer'
          }).append($('<div/>', {
            "class": 'lb-data'
          }).append($('<div/>', {
            "class": 'lb-details'
          }).append($('<span/>', {
            "class": 'lb-caption'
          }), $('<span/>', {
            "class": 'lb-number'
          })), $('<div/>', {
            "class": 'lb-closeContainer'
          }).append($('<a/>', {
            "class": 'lb-close'
          }).append($('<img/>', {
            src: this.options.fileCloseImage
        })))
 )),

          $('<div/>', {"class": 'lb-outerContainer'}).append
          ( $('<div/>', {
                "class": 'lb-container'
              }).append($('<img/>', {
                "class": 'lb-image'
              }), $('<div/>', {
                "class": 'lb-nav'
              }).append($('<a/>', {
                "class": 'lb-prev'
              }), $('<a/>', {
                "class": 'lb-next'
              })), $('<div/>', {
                "class": 'lb-loader'
              }).append($('<a/>', {
                "class": 'lb-cancel'
              }).append($('<img/>', {
                src: this.options.fileLoadingImage
              }))))
          )

)
    ).appendTo($('body'));
  $('#lightboxOverlay').hide().on('click', function(e) {
    _this.end();
    return false;
  });
like image 195
user1327 Avatar answered Feb 01 '26 07:02

user1327


This is YEARS later, but if you want the easiest way to do this by far, simply use the following 4 lines of CSS:

#lightbox {
  display: flex;
  flex-direction: column-reverse;    
}

The flexbox will flip the display order on the container to be in reverse from the DOM.

like image 36
dano Avatar answered Feb 01 '26 08:02

dano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!