Start the thumbnails from the left of the slideshow instead of the middle

南楼画角 提交于 2019-12-25 04:34:03

问题


In the Fotorama plugin, if there are few images then the thumbnails start from the center. I want the thumbnails to start from the left. How can I do this?


回答1:


It is simple. The fotorama plugin uses css3 transform property to align thumbnails under the main image. just calculate the parent width and children container width using jQuery and if the parent is wider than children container, make a transform across X axis to shift all thumbnails to the left.

$(document).ready(function() {
    var pw = $('.fotorama__nav--thumbs').innerWidth();
    var cw = $('.fotorama__nav__shaft').innerWidth();
    var offset = pw -cw;
    var negOffset = (-1 * (pw -cw)) / 2;
    var totalOffset = negOffset + 'px';
    if (pw > cw) {
      $('.fotorama__nav__shaft').css('transform', 'translate3d(' + totalOffset + ', 0, 0)');
    }
});



回答2:


To start the thumbnails from left or right, just add the CSS code:

.fotorama__nav
{
  text-align: left; /*for left*/
}

.fotorama__nav
{
  text-align: right; /*for right*/
}


来源:https://stackoverflow.com/questions/30867297/start-the-thumbnails-from-the-left-of-the-slideshow-instead-of-the-middle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!