我有一份翻译成英文和拉丁文的文本。 我想把英语和拉丁语并列显示在列中。 英语文本通常比拉丁语文本有更多的字符和单词。 我希望拉丁文列的滚动速度比英语列慢,以便用户同时到达两种文本的最后一行。
下面是一些示例代码和示例笔。
使用CSS或JS,这是否可能呢? 我已经找遍了,但没有成功。 提前谢谢!
null
.col {
width: 45%;
margin: 2%;
float: left;
}
<div class="container">
<div class="col">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</div>
<div class="col">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in ligula ex. Aenean tempor metus eu ultrices efficitur. Curabitur at elementum metus. Donec facilisis eros sed volutpat dictum. Morbi pharetra sit amet est at interdum. Cras vitae nulla cursus, posuere leo ut, lacinia neque. Pellentesque hendrerit neque pulvinar gravida egestas. Aenean tempor metus eu ultrices efficitur. Curabitur at elementum metus. Donec facilisis eros sed volutpat dictum. Morbi pharetra sit amet est at interdum. Cras vitae nulla cursus, posuere leo ut, lacinia neque. </div>
</div>
null
这就是你要找的吗?
null
let containerHeight = 200;
let ratio = parseFloat($("#col1")[0].scrollHeight - containerHeight) / parseFloat($("#col2")[0].scrollHeight - containerHeight);
$("#col1").on("scroll", () => {
$("#col2").scrollTop($("#col1").scrollTop() / ratio);
});
.container {
height: 200px;
border: solid 1px #000;
width: 200px;
margin: 2%;
overflow: scroll;
float: left;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container" id="col1">
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem
ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</div>
</div>
<div class="container" id="col2">
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in ligula ex. Aenean tempor metus eu ultrices efficitur. Curabitur at elementum metus. Donec facilisis eros sed volutpat dictum. Morbi pharetra sit amet est at interdum. Cras vitae nulla cursus,
posuere leo ut, lacinia neque. Pellentesque hendrerit neque pulvinar gravida egestas. Aenean tempor metus eu ultrices efficitur. Curabitur at elementum metus. Donec facilisis eros sed volutpat dictum. Morbi pharetra sit amet est at interdum. Cras
vitae nulla cursus, posuere leo ut, lacinia neque.
</div>
</div>
试试这个
.col {
overflow-y: scroll;
height: 200px;
}