$("div.order_status").each(function (i, v) { var statusObject = $(v); var parentWidth = statusObject.parent().width(); var stepCount = statusObject.find("span.s-step").length; var everyWidth = parentWidth / (stepCount + 1); statusObject.css({ paddingLeft: everyWidth }); statusObject.find("span.s-step p").css({ width: everyWidth }); });