0

Lets say i have two divs

<div class="1">
    <div class="2">
    </div>
</div>

Div 1 have this style

width: calc(100% - 22rem);
min-height: calc(100% - 7.75rem);

How can i set div 2 to same size as div1? Because width:100% and height:100% wont work

Sheldon
  • 114
  • 10

2 Answers2

1
position: absolute;

works fine as mentioned by Barbu Barbu

Here's a fiddle for visualization

https://jsfiddle.net/rvzqsgc1/3/

body {
  background-color: black;
}

.div1 {
  position: absolute;
  width: calc(100% - 22rem);
  min-height: calc(100% - 7.75rem);
  background-color: white;
}

.div2 {
  width: 100%;
  background-color: green;
  height: 100%;
  position: absolute;
}
<div class="div1">
  <div class="div2">

  </div>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
David Hänni
  • 71
  • 1
  • 6
1

Try like this, It will work for you.

  body { 
      background: black
    }
    
    .one {
      position: absolute;
      background-color: #FFF;
      width: calc(100% - 22rem);
      min-height: calc(100% - 7.75rem);
    }
    .two {
      position: absolute;
      width: 100%;
      background-color: orange;
      height: 100%;
    }
    <div class="one">
        <div class="two">
        </div>
    </div>
    
  
Ashique Ansari
  • 562
  • 4
  • 14