+ 3

how to display a <div> exactly in the center of the webpage ?

14th Oct 2016, 3:00 PM
Med Fares Omrani
Med Fares Omrani - avatar
3 Respostas
+ 3
.main { height: 150px; width: 400px; display: inline-table; } .paragraph { display: table-cell; vertical-align: middle; text-align: center ; }
15th Oct 2016, 1:48 AM
Sumeet Nagpal
Sumeet Nagpal - avatar
+ 2
margin:0 auto;
17th Oct 2016, 3:39 PM
KelseyCarl
KelseyCarl - avatar
0
There are a few tricks to do this. Check this article (https://css-tricks.com/centering-css-complete-guide/). You can try this code: main { position: relative; height: 200px; width: 60%; margin: 0 auto; padding: 20px; overflow: auto; background: #ddd; } main div{ position: absolute; top: 0; left: 0; bottom: 0; right: 0; margin: auto; width: 50%; height: 50%; overflow: hidden; background: #B63BB6; color: #fff; }
17th Nov 2016, 12:39 AM
Jorge Escamilla
Jorge Escamilla - avatar