【发布时间】:2017-10-25 20:51:25
【问题描述】:
我正在开发一个翻译/词典网站,其中有两列,一列包含文本,另一列包含另一种语言的翻译/含义。
这是我现在所取得的成就的一支笔 https://codepen.io/anon/pen/GMVrvR?editors=0100
HTML
<div class="chapter" style="direction: ltr;">
<p class="">
col#1
</p>
</div>
<div id ="left" class="lines" style="height: 532px; margin-right: -17px;" tabindex="0">
<div class="line" >
<span class="index-no">1</span><span class="">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula</span>
</div>
<div class="line" >
<span class="index-no">2</span><span class="">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo </span>
</div>
<div class="line" >
<span class=" index-no">3</span><span class="">parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula </span>
</div>
<div class="line" >
<span class=" index-no">4</span><span class="">. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</span>
</div>
<div class="line" >
<span class=" index-no">5</span><span class="">Sed fringilla mauris sit amet nibh.</span>
</div>
<div class="line" >
<span class=" index-no">6</span><span class="">Sed fringilla mauris sit amet nibh.</span>
</div>
<div class="line" >
<span class=" index-no">7</span><span class="">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula </span>
</div>
<p class="blank-line"></p>
</div>
</div>
</div>
<div class="block" style="width: 600px; height: 686px; ">
<div class="block-inner">
<div class="chapter" style="direction: ltr;">
<p class="">
col#2
</p>
</div>
<div id ="right" class="lines" style="height: 532px; margin-right: -17px;" tabindex="0">
<div class="line" >
<span class="index-no">1</span><span >Far far away, behind the word mountains, far from the countries Vokalia and Consonantia,</span>
</div>
<div class="line">
<span class="index-no">2</span><span class=""> A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of </span>
</div>
<div class="line" >
<span class="index-no">3</span><span class="">packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her ho</span>
</div>
<div class="line" >
<span class="index-no">4</span><span class="">the first hills of the Italic Mountains, she had a last view back on the skyline of her</span>
</div>
<div class="line" >
<span class="index-no">5</span><span class=""> The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks </span>
</div>
<div class="line">
<span class="index-no">6</span><span class="">the first hills of the Italic Mountains, she had a last view back on the skyline of her</span>
</div>
<div class="line">
<span class="index-no">7</span><span class="">A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of!</span>
</div>
<p class="blank-line"></p>
</div>
</div>
</div>
如您所见,每一列都包含包含文本/翻译的内部 div。
我需要做的是:
使column#1中每个inner div的高度等于column#2中对应inner div的高度,意思是:
col#1 中 div#1 的高度 = col#2 中 div#1 的高度
和
col#1 中 div#2 的高度 = col#2 中 div#2 的高度
等等
请注意:
- 从数据库动态创建的文本和翻译,所以我不知道 div 的大小。
- 有时文字高度会大于翻译高度,而有时翻译高度会更大。
- 我想将滚动条保留在 2 列中,因为我想让用户能够仅滚动一列或滚动相互同步的 2 列,所以我认为将文本和相应的翻译变成一个 div 将不行。
- 会有一个+300的内部div/page,所以如果你用java-script/jquery来解决这个问题,我希望它会很快。
那么让对应的 div 取相同高度的最佳方法是什么?
【问题讨论】:
-
可能您应该在同一行中添加列。我的意思是每个 div 与内部左/右 div
-
我不太喜欢你的评论,我引用了“所以如果你将使用 java-script/jquery 来解决这个问题,我希望它会很快。”。无论如何,我会给你一个领导,自己尝试一下,然后用你自己编写的代码回来,即使它是一个失败的代码,至少你尝试了一些东西。这是一种方法。如果行数始终是偶数,则将两列的每一行的id依次设置为相同,以便它们相互对应,使用javascript获取每个对应行的最大高度,然后使用javascript css func设置所有人的身高。
标签: javascript jquery html css