absolute DIV respect padding of the parent DIV

0

I need to put a div with the property position = absolute . However,% of parent% has div and padding of width: 100% child does not respect this div .

Would the only output would be to set padding to width ?

I'veputanexamplehere:

.master {
  background-color: red;
  width: 200px;
  height: 300px;
  padding: 10px;
  position: relative;
}

.child {
  width: 100%;
  height: 30px;
  background-color: yellow;
  position: absolute;
}
<div class="master">
  <div class="child">
  
  </div>
</div>
    
asked by anonymous 19.07.2017 / 21:47

1 answer

1

If I understand correctly, this is what you want.

*,*:before,*:after{
    box-sizing: border-box;
}

.pai{
    position: relative;
    width: 300px;
    height: 300px;
    background: black;
    padding: 10px;
}

.filho{
width: calc(100% - 10px);
height: 50px;
background: red;
position: absolute;
left: 5px;
}
<div class="pai">
        <div class="filho">
            
        </div>
    </div>
    
19.07.2017 / 21:52