| Please give the OP the benefit of the doubt and assume that he or she is a competent professional. Here are some situations where you may want to test your understanding of centering in CSS: + Center an absolute positioned element whose width and height are unknown (e.g., it's an <img>). + Does anything change if the parent element has padding? + Create an element that's width 50%, height 50%, and center it in a parent of unknown size. + Do any of these solutions still work if all elements have a 10px border? + Which of these solutions will remain centered if the parent has smaller width/height than the child? How confident are you in any of these solutions without being able to run them? CSS is quite complex. It was built up incrementally by reasonable, intelligent people trying to solve hard problems. If you're convinced that things are easy or that other people struggle simply because they are lazy, then you'll never be able to learn and grow your own skills. <3 |
The article OP mentioned[0] is from 2011 and antiquated unless you're writing for IE8 or below (which, of course, could still be a requirement).
I was merely trying to point out a better solution to OP's face-value problem and suggest a new CSS pattern that I personally have grown to love.
@iambateman - feel free to email me if you want some help learning some of these CSS techniques. I'll gladly walk you through them and answer any questions that I can.
@lynghk - cheers, thanks for your comment.
[0] https://css-tricks.com/centering-in-the-unknown/