0

How do I get the text over the picture? The picture has to start on the yellow right side and not on the red right side. I can't think of any other way to implement this layout. What do I have to do differently?

body {
  margin: 0;
}

.relative-1 {
  margin: 0;
  background-color: yellow;
  position: relative;
  width: 100vw;
  height: 100vh;
}

.absolute-1 {
  width: 100px;
  height: auto;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.absolute-2 {
  width: 90vw;
  height: 90vh;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: red;
}

.absolute-3 {
  margin: 0;
  position: absolute;
  right: 0;
  top: 50%;
  z-index: 99;
}
<div class="relative-1">
  <img class="absolute-1" src="https://upload.wikimedia.org/wikipedia/commons/e/eb/Ash_Tree_-_geograph.org.uk_-_590710.jpg">
  <div class="absolute-2">
    <p class="absolute-3"> Test Test Test Test Test Test</p>
  </div>
</div>
software
  • 83
  • 7

0 Answers0