Guest User

Untitled

a guest
Jun 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. var measure= document.createElement('div');
  2. measure.style.height= '10em';
  3. document.body.appendChild(measure);
  4. var size= measure.offsetHeight/10;
  5. document.body.removeChild(measure);
  6.  
  7. p {
  8. font-size:2em;
  9. }
  10.  
  11. body {
  12. font-size:0.625em;
  13. }
  14.  
  15. p {
  16. font-size:2em;
  17. }
  18.  
  19. $(window).resize(resize); // update when user resizes the window.
  20.  
  21. $("body").append("<p id='textSizeReference' style='display:none;padding:0'>T</p>");
  22. var refTextHeight = $("#textSizeReference").height();
  23. setInterval(function() {
  24. var h = $("#textSizeReference").height();
  25. if (h != refTextHeight) {
  26. refTextHeight = h;
  27. resize(); // update when user changes text size
  28. }
  29. }, 500);
Add Comment
Please, Sign In to add comment