Align block to the center (pseudo-class 6)

https://habr.com/ru/post/238449

by Serhio Magpie

HTML

<div class="parent">
  <img class="block" src="https://habrastorage.org/files/d74/7e5/b15/d747e5b153204276b6e0b02f53d765ff.jpg" alt="">
</div>

CSS

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.parent {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  white-space: nowrap;
  text-align: center;
  font-size: 0;
}
.parent::before {
  height: 100%;
  display: inline-block;
  vertical-align: middle;
  content: '';
}

.block {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  display: inline-block;
  white-space: normal;
  vertical-align: middle;
  text-align: left;
  background: #60a839;
}