Flexslider <li> height's equal the tallest <li> on a mobile browser

杀马特。学长 韩版系。学妹 提交于 2019-11-28 08:58:21

问题


I am trying to figure out an issue with Flexslider that only appears when I test it on an mobile browser such as Safari Mobile.

All of the <li> containers are the same height as the tallest <li>, even when there is not enough content to justify making them equal heights.

I am not sure how to grab a screen shot of this since it works fine on a desktop browser but not on mobile browsers. Here's a fiddle that shows it working as I would expect when I view it on my desktop browser, the container's height resizes depending on the ammount of content.

http://jsfiddle.net/CsCyh/

Here is the hml:

<div class="flexslider">
  <ul class="slides">
    <li>
      <img src="http://i.imgur.com/YSVlz2Z.jpg" />
      <h2><a href"#">First Link Here</a></h2>
      <p>Some text here that could be a message</p>
      <a href="#" data-role="button" data-icon="arrow-r" data-iconpos="right">Another Link Here</a>
    </li>
    <li>
      <img src="http://i.imgur.com/YSVlz2Z.jpg" />
      <h2><a href"#">Second Link Here</a></h2>
      <p>Some text here that could be a message</p>      
    </li>
    <li>
     <img src="http://i.imgur.com/YSVlz2Z.jpg" />
     <h2><a href"#">Third Link Here</a></h2>
     <p>Some text here that could be a message</p>     
    </li>
  </ul>
</div>

Here's the JS for flexslider:

$('.flexslider').flexslider();

回答1:


Hmm, I ran into this issue awhile ago. I hope this helps!

var evenSliderHeight = function(slideContainer, slideItem) {
  var slider_height = 0;
  var $slider_slide = $(slideContainer).find(slideItem);
  $slider_slide.each(function() {
    var __height = $(this).outerHeight(true);
    if ( slider_height < __height ) {
       slider_height = __height;
    }
  });
  $slider_slide.css('min-height', slider_height);
};
evenSliderHeight('.flexslider-container', '.slide');



回答2:


$('.flexslider').flexslider({
  after: function(slider){
    currHeight = $('.flexslider').find('.slides > li').eq(slider.currentSlide).outerHeight(true);
    $('.flexslider').height(currHeight);
  }
});

JSFiddle Update: http://jsfiddle.net/CsCyh/14/





回答3:


Add this to the script that calls the slider.

animateHeight: false,

eg.:

$(window).load(function(){ if ( $('#content-slider-wrap').length == 0 ) return false
    $('#content-slider-wrap').flexslider({
        animation:"fade",
        slideshow: true,
        directionNav: true,
        animateHeight: false,
        controlNav:false ,
........... etc etc


来源:https://stackoverflow.com/questions/15752070/flexslider-li-heights-equal-the-tallest-li-on-a-mobile-browser

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