Advertisement
briank

Kartra Fixed (Non-Scrolling) Membership Background

Apr 9th, 2022 (edited)
2,436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.51 KB | None | 0 0
  1. <!--
  2. You do NOT need to include this comment block. Copy and paste from the <p> paragraph below.
  3. Replace the background-image URL with the storage location of your image. The image will be scaled to fit the width of the screen/window.
  4. Change the second background-position % between 0% (to anchor the top of the image to the top of the window) and 100% (to anchor the bottom of the image to the bottom of the window).
  5. The code block should be at the top (or at least not last) and will be hidden in preview and live.
  6. Note: Some browsers do not honor fixed backgrounds and will scroll them (e.g. Safari mobile).
  7. -->
  8.  
  9. <!-- The following label is an editing aid and will not appear in live -->
  10. <p>Background Image</p><!-- membership-background-color-image -->
  11. <script>
  12. if ('app.kartra.com' !== location.hostname) document.currentScript.parentElement.parentElement.style.display = 'none';
  13. </script>
  14. <style>
  15. body::before {
  16. content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  17. background-color: inherit; opacity: 1.0;
  18. background-image: url("https://d1aettbyeyfilo.cloudfront.net/kcsg/unsplash_1581286117.jpg"); /* 16w:9h image */
  19. background-repeat: no-repeat;
  20. background-attachment: fixed;
  21. background-size: 100vw; /* default: scale to viewport width; crop T/B */
  22. background-position: 50% 100%;
  23. }
  24. @media (min-height: 56.25vw) { /* Adjust if not 16w:9h image */
  25.     /* If viewport height:width exceeds 9:16, scale to viewport height; crop L/R */
  26.     body::before { background-size: auto 100vh; }
  27. }
  28. </style>
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement