cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <main>

  <h1>Filtering for WHCM</h1>

  <p>
    Let’s pretend this is the page of a site that follows the incredibly creative and unique layout of three items with an image (in this case SVG) and some following text.
  </p>

  <div>

    <article>
      <h2>The First Example</h2>
      <p>
        The SVG in this chunk is a background image. It is black to demonstrate the light-on-dark media query.
      </p>
    </article>

    <article>
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/speech_white.svg" alt="">
      <h2>The Second Example</h2>
      <p>
        This chunk uses an <code>&lt;img&gt;</code> to provide the SVG image. It is white to demonstrate the dark-on-light media query.
      </p>
    </article>

    <article>
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/firefox-logo.svg" alt="">
      <h2>The Third Example</h2>
      <p>
        One is a CSS background image, the other is an <code>&lt;img&gt;</code>, but both are in full color.
      </p>
    </article>

  </div>

  <p>
    For the post <cite><a href="http://adrianroselli.com/2018/03/svg-filtering-for-windows-high-contrast-mode.html">SVG Filtering for Windows High Contrast Mode</a></cite>.
  </p>
  
</main>


            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Lato:400,700);

body {
  background-color: #6d695c;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAA3RSTlMmDQBzGIDBAAAAG0lEQVR42uXIIQEAAADCMHj/0NdkQMws0HEeAqvwAUGJthrXAAAAAElFTkSuQmCC);
  font-size: 100%;
  color: #333;
  font-family: Lato, Arial, sans-serif;
  padding: 0;
  margin: 0;
}

main {
  display: block;
  box-sizing: border-box;
  width: 90%;
  margin: 1em auto;
  padding: 1em 2em;
  color: #000;
  background-color: rgba(204, 204, 204, 0.7);
  border: 0.07em solid rgba(0, 0, 0, 0.5);
  border-radius: 0.5em;
}

h2 {
  text-align: center;
}

img {
  height: 4em;
  width: auto;
  display: block;
  margin: 0 auto;
  transition: all 0.1s ease-in-out;
}

article {
  background-repeat: no-repeat;
  background-position: 50% 0;
  background-size: auto 4em;
}

article:first-child {
  padding-top: 4em;
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/phone.svg);
}

article:nth-child(3) {
  background-position: 67% 0;
  background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/firefox-logo.svg");
}

article:nth-child(3) img {
  margin: 0 0 0 calc(33% - 2em);
}

main > div {
  display: flex;
  flex-wrap: wrap;
  margin: 2.5em -1em 0 -1em;
}

article {
  flex: 1 0 10em;
  margin: 0.5em 1em;
}

/* Windows High Contrast Mode Support */
@media screen and (-ms-high-contrast: active) {
  article:nth-child(3) {
    filter: contrast(400%);
  }
/*   article:nth-child(3)::after {
    content: 'active';
  } */
}

@media screen and (-ms-high-contrast: black-on-white) {
  article:nth-child(2) img {
    filter: invert(100%);
  }
/*   article:nth-child(2)::after {
    content: 'black-on-white';
  } */
}

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: white-on-black) {
  article:first-child {
    filter: invert(100%);
  }
  article:first-child p,
  article:first-child h2 {
    filter: invert(100%);
  }
/*   article:nth-child(1)::after {
    content: 'white-on-black';
  } */
}

            
          
!
999px
Loading ..................

Console