【问题标题】:Scalable site in parts部分可扩展站点
【发布时间】:2011-08-22 10:58:28
【问题描述】:
【问题讨论】:
标签:
jquery
css
resize
width
scalable
【解决方案1】:
这是一个应该做你想做的脚本:
function adaptTitleWidth() {
// reset default style
$(".box").css("background","purple");
// get the first row of boxes (the first box and the boxes having the same offset().top
firstRowBoxes = $(".box").filter(function() {
return $(this).offset().top === $(".box:first").offset().top;
// changes the first row of boxes background to blue
}).css("background","blue");
// changing .logo.width() : number of boxes on the first row * outer width of the boxes, margin included - the last margin-right
$(".logo").width(firstRowBoxes.length * $(".box:first").outerWidth(true) - parseInt($(".box:first").css("margin-right")));
}
$(function() {
adaptTitleWidth();
window.onresize = function(event) {
adaptTitleWidth();
}
});
jsBin example here