<div id="xm_title" style="background:#fff;width:100%;overflow-y:scroll;white-space: nowrap;">
<span class="typeBox" style="display:inline-block;background:#eee;color:#888;border-radius:5px;padding:0 10px;margin:0 5px;font-size:13px" onclick="click_type(this)">菜单一</span>
<span class="typeBox" style="display:inline-block;background:#eee;color:#888;border-radius:5px;padding:0 10px;margin:0 5px;font-size:13px" onclick="click_type(this)">菜单二</span>
</div>
var moveX = $(obj).position().left + $(obj).parent().scrollLeft();
var pageX = document.documentElement.clientWidth; //设备的宽度
var blockWidth = $(obj).width();
var left = moveX - (pageX / 2) + (blockWidth / 2);
$("#xm_title").animate({ scrollLeft: left }, 500);