-1

div1 is in the centre of screen and I want div2 in the centre of div1

<div id="div1">
       <div id="div2"></div> 
    </div>

css:

 #div1{ 
     top:0;
     left:0;
     right:0;
     bottom:0;
     margin:auto;
     position:fixed;
     width:595px;
     height:842px;
     background-color:#F0F0F0;
 }

#div2{

}
Dinesh Kanivu
  • 2,551
  • 1
  • 23
  • 55
G.D
  • 181
  • 7

1 Answers1

0
<style>
#div1{ 
 top:0;
 left:0;
 right:0;
 bottom:0;
 margin:auto;
 position:fixed;
 width:595px;
 height:842px;
 display:table;
 }

#div2{
display:table-cell;
vertical-align: middle;
margin:auto; 
background-color:red;
position:relative;
}

</style>
<div id="div1">
   <div id="div2">content</div> 
</div>

js fiddle here https://jsfiddle.net/GlynneT/06uzt7xx/