News for hackers. Stuff that matters.
Re:“Tomato” versus “#FF6347” – the tragicomic history of CSS... by sltkr on Thursday October 15, 2015 @05:44PM (#10396223)
> No you don't. There are well-documented, consistent ways to centre in CSS. Vertical entering used to be difficult (for obvious reasons), but now we've got flexbox which solves that problem entirely.

So, what's the way to put something in the center?

Re:“Tomato” versus “#FF6347” – the tragicomic history of CSS... by 0x4a42 on Thursday October 15, 2015 @07:28PM (#10396626)
Pick the one that you find the more "sane":

  /* method1: flexbox hack */
  .container {
    display: flex; /* opt into the new box model */ 
    justify-content: center; /* "align" */
    align-items: center; /* "valign" */
  }

  /* method2: table hack */
  .container {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
  }

  /* method3: translate hack */
  /* hack to fix bad rendering */
  .container {
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    transform-style: preserve-3d;
  }

  /* center me */
  .element {
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
etc...
Re:“Tomato” versus “#FF6347” – the tragicomic history of CSS... by swhipple on Thursday October 15, 2015 @07:47PM (#10396713)
Just to add to your post, the reason that there are multiple ways to "center something" is because tables and flexboxes have different behaviors, especially for multiple children, and the third case of arbitrary translation, but all can be made to give the same visual effect here -- the specific case of aligning and valigning a single child to the center of the parent.

In my experience though, the flexbox model is the only example of DWIM in the majority of cases (the only surprise I've had was some situation with an overflowed child inside of a flexbox and requiring an explicit min-height: 0 [1]... something that seemed unintuitive, but modern browsers are beginning to support uniformly).

[1] https://code.google.com/p/chromium/issues/detail?id=506893

Re:“Tomato” versus “#FF6347” – the tragicomic history of CSS... by iopq on Thursday October 15, 2015 @06:13PM (#10396356)
<!--[if lte IE 8]> <p>You aren't using a recent version of Internet Explorer.</p> <![endif]-->

and then you center things