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: ->

  getInitialState: ->
    width: null

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

  render: ->
      <div style=>

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.