EduardET

CSS: Lazy Load Youtube Videos

Dec 15th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.96 KB | None | 0 0
  1. .youtube {
  2.     background-color: #000;
  3.     margin-bottom: 30px;
  4.     position: relative;
  5.     padding-top: 56.25%;
  6.     overflow: hidden;
  7.     cursor: pointer;
  8. }
  9. .youtube img {
  10.     width: 100%;
  11.     top: -16.84%;
  12.     left: 0;
  13.     opacity: 0.7;
  14. }
  15. .youtube .play-button {
  16.     width: 90px;
  17.     height: 60px;
  18.     background-color: #333;
  19.     box-shadow: 0 0 30px rgba( 0,0,0,0.6 );
  20.     z-index: 1;
  21.     opacity: 0.8;
  22.     border-radius: 6px;
  23. }
  24. .youtube .play-button:before {
  25.     content: "";
  26.     border-style: solid;
  27.     border-width: 15px 0 15px 26.0px;
  28.     border-color: transparent transparent transparent #fff;
  29. }
  30. .youtube img,
  31. .youtube .play-button {
  32.     cursor: pointer;
  33. }
  34. .youtube img,
  35. .youtube iframe,
  36. .youtube .play-button,
  37. .youtube .play-button:before {
  38.     position: absolute;
  39. }
  40. .youtube .play-button,
  41. .youtube .play-button:before {
  42.     top: 50%;
  43.     left: 50%;
  44.     transform: translate3d( -50%, -50%, 0 );
  45. }
  46. .youtube iframe {
  47.     height: 100%;
  48.     width: 100%;
  49.     top: 0;
  50.     left: 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment