use offsetWidth instead of width of element