简体   繁体   English

将水平滚动条位置设置在最右边

[英]Set horizontal scrollbar position to the rightmost

I'm making a website where you read articles by scrolling towards right similar to the windows 10 desktop apps. 我正在建立一个网站,您可以在其中滚动阅读内容,类似于Windows 10桌面应用程序。

I want to make sure that when the article loads, the page should display the end of the article, ie; 我要确保在加载文章时,页面应显示文章的结尾,即; the scrollbar must be to the rightmost and then animate the scrollbar to move to the left (ie; towards the beginning of the article) so that first time users know about the reading layout. 滚动条必须位于最右边,然后使滚动条具有动画效果以向左移动(即,朝向文章的开头),以便首次用户知道阅读布局。

I'm also using CSS columns to break down the articles into columns. 我还使用CSS columns将文章分为几列。 I tried using scrollLeft() to set scrollbar position to the rightmost but I don't know how to calculate the width of the article spanning horizontally 我尝试使用scrollLeft()将滚动条位置设置为最右边,但是我不知道如何计算水平跨度的文章宽度

How can I do this? 我怎样才能做到这一点?

HTML : HTML:

<div class="entry-content">
...

...

...

</div>

contains the article 包含文章

CSS : CSS:

.entry-content {
    column-count: 3;
    max-height: 500px;
    overflow-y: hidden;
}

Here is the link to the fiddle 这是小提琴的链接

You need get the full width of the element. 您需要获取元素的完整宽度。

   var left = $('.entry-content').width();
   $('.entry-content').scrollLeft(left);

Demo : https://jsfiddle.net/kishoresahas/9ynasean/1/ 演示: https : //jsfiddle.net/kishoresahas/9ynasean/1/

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

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