Wednesday, 15 December 2021

CSS Activity

 Child div inside Parent div 

HTML & CSS code 



Child div is having yellow color & Parent div is having red. Apply CSS in such a way that yellow div should be align exactly in the middle of red div.

Ans: .parent{

  width:200px;

  height:200px;

  background-color:red;

  display: flex;

  justify-content: center;

  position: relative;

}

.child{

  width:100px;

  height:100px;

  background-color:yellow;

  position: absolute;

  top: 50%;

  transform: translate(0, -50%);

}


Posted By: pankaj_bhakre

No comments:

Post a Comment