11-26-filter-grayscale-contrast.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Grayscale and contrast filter</title>
  6. <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Roboto:400,700" rel="stylesheet" type="text/css">
  7. <style>
  8. img {
  9. max-width: 100%;
  10. }
  11. .universe-header {
  12. max-width: 450px;
  13. position: relative;
  14. -webkit-filter: grayscale(70%) brightness(0.7) contrast(2);
  15. filter: grayscale(50%) contrast(1.5);
  16. }
  17. :root .universe-title {
  18. margin: 0;
  19. width: 90%;
  20. height: 0;
  21. padding-bottom: 27%;
  22. position: absolute;
  23. left: 5%;
  24. right: 5%;
  25. top: 54%;
  26. font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  27. }
  28. .universe-title text {
  29. fill: #602135;
  30. text-transform: uppercase;
  31. }
  32. .universe-title svg {
  33. position: absolute;
  34. top: 0;
  35. right: 0;
  36. bottom: 0;
  37. left: 0;
  38. background-color: #fff;
  39. }
  40. @supports (mix-blend-mode: screen) {
  41. /**
  42. * 1. Only add the mix-blend-mode rules if supported. Screen makes black
  43. * 100% transparent.
  44. * 2. Change the fill color to black for supporting browsers,
  45. * resulting in 100% transparency for the text.
  46. */
  47. .universe-title {
  48. mix-blend-mode: screen;
  49. }
  50. .universe-title text {
  51. fill: #000;
  52. }
  53. }
  54. .universe-span-1 {
  55. font-size: 53.2px;
  56. }
  57. .universe-span-2 {
  58. font-size: 96.2px;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <header class="universe-header">
  64. <h2 class="universe-title">
  65. <svg viewBox="0 0 400 120" role="img" aria-labelledby="universe-title-textcontent">
  66. <text id="universe-title-textcontent">
  67. <!-- Put both tspan elements on same line, to prevent bug in WebKit. -->
  68. <tspan class="universe-span-1" x="6" dy="0.8em">The Observable</tspan> <tspan class="universe-span-2" x="3" dy="0.75em">Universe</tspan>
  69. </text>
  70. </svg>
  71. </h2>
  72. <img class="fig fig-universe" src="img/universe.jpg" alt="A starscape with far galaxies.">
  73. </header>
  74. </body>
  75. </html>