问题
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