Advertisement
Guest User

Untitled

a guest
Mar 19th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //JS
  2. const maxWindowWidth = 500;
  3. const htmlElement = document.querySelector("html");
  4.  
  5. function setWindowScale() {
  6. if (window.innerWidth > maxWindowWidth) {
  7. const scale = window.innerWidth / maxWindowWidth;
  8. htmlElement.style.transform = `scale(${scale})`;
  9. }
  10. }
  11.  
  12. setWindowScale();
  13. window.addEventListener("resize", setWindowScale);
  14.  
  15.  
  16. //CSS
  17. @media (min-width: 500px) {
  18. html {
  19. transform-origin: 0px 0px;
  20. height: 656.25px;
  21. width: 500px;
  22. position: absolute;
  23. }
  24. }
  25.  
  26. @media (max-width: 499px) {
  27. html {
  28. transform: unset !important;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement