Centering with transform

/*Horizontal center:*/ .horizontal-center { left: 50%; transform: translateX(-50%); } /*Vertical center:*/ .vertical-center { top: 50%; transform: translateY(-50%); } /*Both horizontal and vertical:*/ .absolute-center { left: 50%; top: 50%; transform: translate(-50%, -50%); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.