我正在尝试使 div 具有浏览器窗口的完整宽度和高度,这是我拥有的代码。它不起作用。
jQuery:
<script type="text/javascript">
var viewportWidth = $(window).width();
var viewportHeight = $(window).height();
$('#lordy').css('height', viewportHeight + 'px');
$('#lordy').css('width', viewportWidth + 'px');
$(window).resize(function() {
var viewportWidth = $(window).width();
var viewportHeight = $(window).height();
$('#lordy').css('height', viewportHeight + 'px');
$('#lordy').css('width', viewportWidth + 'px');
});
HTML
<div id="lordly"></div>
CSS
#lordly {
background-color: #CB0011;
}