Here’s a ReactJS component which ensures that it’s children are rendered inside a container whose width is evenly divisible by 8:

@SnapTo8px = React.createClass
  componentDidMount: ->
    @_resize()
    $(window).resize(@_resize)

  getInitialState: ->
    width: null

  _resize: ->
    @setState
      width: Math.floor($(@getDOMNode()).parent().width() / 8) * 8

  render: ->
    `(
      <div style=>
        {this.props.children}
      </div>
    )`

Why? It’s part of my chess site which uses the Bootstrap grid, and for ideal rendering, it helps to have the div containing the chess board be an exact multiple of 8 so that the squares are not fractional pixels wide.