简体   繁体   English

滑块高度不相等

[英]slider heights are not equal

I have four sliders with different heights, I want to set same height for all sliders and height should be evaluvated from each slider. 我有四个高度不同的滑块,我想为所有滑块设置相同的高度,并且应该从每个滑块中评估高度。 So I'm using each condition and checking the values based on each slider values. 所以我正在使用每个条件,并根据每个滑块值检查值。 But the problem is one slider is not working which one is large height. 但是问题是一个滑块不起作用,而那个滑块高度很大。 Please suggest what is the issue. 请提出问题所在。

JS JS

   var maximum = null;

    $('.lgi-grouping-responsive').each(function() {
        var value = parseFloat($(this).height());
        maximum = (value > maximum) ? value : maximum;

    });

HTML HTML

<div class=".lgi-grouping-responsive">Continue running background apps when Google Chrome is closed
</div>
<div class=".lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed</div>
<div class=".lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed
</div>
<div class=".lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed
</div>

In your html, you don't need to add the "." 在您的html中,您无需添加“。” in front of the class name. 在班级名称前面。 Just write: 写吧:

<div class="lgi-grouping-responsive">

The "." “。” is used for jquery to pick up all the divs with that classname. 用于jquery拾取具有该类名的所有div。 I've put your code into a working fiddle for you. 我已将您的代码放入工作中的小提琴中。 You'll see all the divs end up with the same height (maximum): 您会看到所有div最终都具有相同的高度(最大):

 var maximum = 0; var $biggestDiv = null; $('.lgi-grouping-responsive').each(function() { var value = parseFloat($(this).height()); if (value > maximum) { maximum = value; $biggestDiv = $(this); } }); $('.lgi-grouping-responsive').not($biggestDiv).css("height", maximum); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="lgi-grouping-responsive">Continue running background apps when Google Chrome is closed </div> <div class="lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed</div> <div class="lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed </div> <div class="lgi-grouping-responsive">Continue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closedContinue running background apps when Google Chrome is closed Continue running background apps when Google Chrome is closed </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM