Overlap div over another and position in upper right corner

1

How can I overlay one div with another and always place it fixed in the upper right corner always in relation to the div that it is inserted? I tried with z-index e position:absolute but did not succeed.

    
asked by anonymous 06.12.2016 / 15:23

1 answer

1

You need to use not only absolute position in the div that will overlap, but also position relative in the parent div. Here's an example: link

html, body {
  height: 100%;
  width: 100%;
}

.one {
  background-color: red;
  height: 100%;
  position: relative;
  width: 100%;
}

.two {
  background-color: blue;
  height: 100px;
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
}
<div class="one">
  <div class="two"></div>
</div>

Any questions please send me a bullet;)

    
06.12.2016 / 15:34