Set Middle and center for div

html <div id=”container”> <div id=”box”></div> </div> CSS   * {margin:0;padding:0} #container { border: 2px solid blue; position: relative; width: 400px; height: 300px; background: url(http://i2.wp.com/webfaver.com/wp-content/uploads/2015/07/square.png) no-repeat center center; } #box { border: 2px solid red; position: absolute; width: 80px; height: 160px; left: 50%; top: 50%; transform: translateX(-50%) translateY(-50%); -webkit-transform: translateX(-50%) translateY(-50%); } * {margin:0;padding:0} #container {…