Positionierung mit inset

by Rolf

HTML

<div id="a">
  <div id="b">
  </div>
</div>

CSS

#a {
  margin-block-start: 5em;
  background-color: #f88;
  width: 20em;
  height: 20em;
  position: relative;
}
#a::before { /* Helper zur Darstellung von 50% und 1em ĂĽber 50% */
  content: " ";
  position: absolute;
  box-sizing: border-box;
  width: 200%;
  height: 1em;
  background-color: #AAA5;  /* Teiltransparent */
  top: calc(50% - 1em);
}
#b { 
  background-color: #8f8;
  position: absolute;
  width: 10em;
  height: 5em;
  inset-block-end: calc(50% + 1em);
  inset-inline-start: calc(100% + 2em);
  /* oder in einem:
      inset: auto auto calc(50% + 1em) calc(100% + 2em) */
}