由于您使用的是 jQuery,因此您可以在菜单上进行一些数学运算。
编辑:把这个放在你的头标签结束之前
LAST_EDIT:这是 JS 小提琴http://jsfiddle.net/BsnFW/14/。最后一次尝试:)
$(document).ready(function() {
menuBreakPoint = 200; //width in px after which you want to insert the space (experiment with this)
menuWidth = 0;
rightMenuStart = 600; //width in px from left of menu container div to the right
$('.sub_site_menu li').each( function() {
menuWidth += $(this).width();
if (menuWidth >= menuBreakPoint) {
$(this).css('margin-left', (rightMenuStart - menuWidth));
return false; //break out of each loop
}
});
});
用这个。