Superimpose div on another and position in the upper right corner

Asked

Viewed 1,885 times

1

How can I overlap one div with another and always position 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 I did not succeed.

inserir a descrição da imagem aqui

1 answer

1

You need to use not only Absolute position in the overlapping div, but also relative position in the parent div. Follow an example: http://codepen.io/leofontes/pen/VmxZoN

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 doubt sends bullet that I help you ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.