how to calculate height of scroll content

◇◆丶佛笑我妖孽 提交于 2021-02-11 13:48:25

问题


I'm developing Hybrid app using ionic-3. I want to display vertical line in center of the page and my page have dynamic data so we can't set height of this line. I have display view of my page in below image. I have put div and set as absolute and give border left with 100% height but when i scroll line is no longer. So i just want to calculate height to scroll content and i'll set it dynamically. Let me know if you have better solution for it.

Thank you.


回答1:


Create Viewchild for your element in component

@ViewChild('myScrollY') scrollY: ElementRef;

add #myScrollY to your element

in component u can get it with below code

this.scrollY.nativeElement.scrollHeight;



回答2:


For this specific issue there are some other ways to solve the issue.

1) You could add a pseudo element and position it absolute in the wrapping container 2) Add a background with a line in it.



来源:https://stackoverflow.com/questions/61339421/how-to-calculate-height-of-scroll-content

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