2017
CSS - ONLINE TOOL - How to Center in CSS
by 3 othersCentering in CSS is a pain in the ass. There seems to be a gazillion ways to do it, depending on a variety of factors. This consolidates them and gives you the code you need for each situation.
Select the type of content you want to center in a parent div and the size of the parent.
2015
CSS - html - Horizontally center a div in a div - Stack Overflow
Centering a div of unknown height and width
Horizontally and vertically. Works with reasonably modern browsers (FF, Safari/Webkit, Chrome, IE10, Opera, etc.) ____
.content {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
2013
CSS - Centering Percentage Width/Height Elements | CSS-Tricks
by 1 other (via)If you know the exact width/height of an element, you can center it smack dab in the middle of its parent element easily with this classic trick: top and left set to 50% and negative margins half the width and height of the element. That's great if you know the width and height of the element you're trying to center, but what if they are percentages?
1
(3 marks)