【发布时间】:2013-12-06 13:57:50
【问题描述】:
尝试将边框宽度更改为窗口的宽度。 让这段代码工作:
jQuery(window).ready(function($) {
var windowWidth = $('#portfolio_title .container').outerWidth();
$('.topBorder').css({'border-right-width':(windowWidth)+'px'});
$('.btmBorder').css({'border-left-width':(windowWidth)+'px'});
$(window).resize( function(){
var windowWidth = $('#portfolio_title .container').outerWidth();
$('.topBorder').css({'border-right-width':(windowWidth)+'px'});
$('.btmBorder').css({'border-left-width':(windowWidth)+'px'});
});
});
但它并不漂亮 尝试像这样优化它:
jQuery(document).ready(myWidth);
jQuery(window).resize(myWidth);
function myWidth($){
var windowWidth = $('#portfolio_title .container').outerWidth();
$('.topBorder').css({'border-right-width':(windowWidth)+'px'});
$('.btmBorder').css({'border-left-width':(windowWidth)+'px'});
};
文档就绪工作但调整大小没有。 我做错了什么?
【问题讨论】: