2 :
, 100% , , , 100% , , , , :
function justifyCenter() {
var navWidth = $("nav").width();
var itemWidth = $(".item:first-child").width();
if (navWidth === itemWidth ) {
$("nav").addClass('justify-center');
} else {
$("nav").removeClass('justify-center');
}
}
Codepen demo: https://codepen.io/anon/pen/WzgpLw