by
30 4
0
3
59
1
Tagged
Specified
OpenSource
Created
Modified Mar 14, 2019

Published on:

Languagecss
LicenseMIT_X11

Centre child inside its parent - Old School Way

How to centre a div vertically and horizontally inside its parent
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4417949/Centre-child-inside-its-parent---Old-Sch?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/* Center a div - The old school way*/ .parent { /* Center my child relative to me */ position: relative; } .child { /* Center me inside my parent*/ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus