Skip to main content

Posts

Showing posts from July, 2020

3 Best Ways to center a div inside a div using css only

I will talk about 3 ways to 'Center a div inside a div using css'. All the 3 methods are very easy and even a beginner can understand the concept. However i will also provide the code in this post.  Stay Tuned till the last method as i will center a div inside another div by using just 2 lines of code OUR CODE'S PRE WORKOUT Follow these 3 steps before using any of the method to center a div inside a div.  1. Before You use any of the trick to center the div using css make sure you have removed the by default margin (8px) and padding (8px) and don't forget to set box sizing to border box. Code to do the magical stuff : * {      margin :  0 ;      padding :  0 ;      box-sizing :  border-box ; } 2 .I assume that you have marked the class of main div as class="parent_div" and the class of inner div as class="child_div" 3. Now I will give  blue color  so that we can check the div easily and can debug ac