1

I'm building the web application which uses canvas surface on top of HTML body. I use canvas to draw border around SPANs. It works nearly perfectly but I still have a problem on the page load.

I've used chrome debugger and noticed that font style from css file is applied after script execution which confuses DOM getElementRects method and causes that the spans border is mispositioned after page is fully rendered. Below I'm attaching screenshots.

enter image description here enter image description here

Do you have any idea how to solve that? Can I wait on until css style is fully applied?

2 Answers 2

1

Font loading takes some more time than css loading take help of following -> How to be notified once a web font has loaded

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it was problem with waiting for font-face. Thank you.
1

Is $(document).ready() also CSS ready?

The ready() method no longer tries to make any guarantees about waiting for all stylesheets to be loaded. Instead all CSS files should be included before the scripts on the page. More Information

Make sure your scripts are on the bottom of the html page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.