Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

A Centered Responsive Image With Matte And Border

I've been searching for CSS to display images in a gallery style. Ones with a black pen line border on a white matte style background. More importantly, I want them designed so that when they are centered in the viewport 100% of both the image and the matte are visible.

I've taken a few different runs at it and finally got to this:

CSS

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

.matteWrapper {
  display: grid;
  place-items: center;
  margin-block: 3rem 4rem;
}

.matteWrapper img {
  background-color: black;
  padding: 2px;
  border-top: 10vmin solid white;
  border-left: 10vmin solid white;
  border-right: 10vmin solid white;
  border-bottom: 12vmin solid white;
  max-height: min(94vh, 98vb);
  max-width: min(94vw, 98vi, 100%);
}

Here's a couple of examples followed by the code. Resize your browser a bunch to see the behavior.

I'm still a yellow belt when it comes to CSS, but as far as I can tell this is doing everything I want.