0

I have a container div like this:-

<div class="container">
<div class="parent"></div>
<div class="child"></div>
</div>

I want to overlay the child div like this But without touching the parent div css. How can I achieve this. I'll appreciate any kind of suggestions.

Viira
  • 3,805
  • 3
  • 16
  • 39

1 Answers1

0

It is not clear from what you want to achieve but can try some of the below stuf :

  • You can achieve that by using top/bottom/left/right property and position: relative to the .child according to need.

  • You can achieve by using extra container and add display: flex;width:100% and using justify-content properties according to need .

  • float: left/right can also be used according to need(but you will not able to position other than left, right and use margin)

  • Simply by top/bottom/left/right margin can achieve the position .

* {
  box-sizing: border-box;
}

.container {
  position: relative;
  width: 400px;
  height: 300px;
  border: 3px solid #73AD21;
}

.parent {
  width: 200px;
  height: 80px;
  margin: 10px;
  border: 3px solid #73AD21;
}

.child {
  position: relative;
  left: 180px;
  width: 200px;
  height: 100px;
  border: 3px solid #73AD21;
}
<div class="container">
  <div class="parent"></div>
  <div class="child"></div>
</div>
Rana
  • 2,500
  • 2
  • 7
  • 28