0

I am using this code

//Resize Div    
$(document).ready(function(){
    resizeDiv();
});

window.onresize = function(event) {
    resizeDiv();
}

function resizeDiv() {
    vpw = $(window).width();
    vph = $(window).height();
    $('.site-intro').css({'height': vph + 'px'});
}

It works great and makes the first div 100% of the window and set the height inline. Is there a way to add to this code so it would make other divs set to the same height?

I am placing one div on top of the other and want them all to be the same height (that same height being what ever 100% is).

Sorry,

The HTML

<div class="wrapper">
<div class="site-intro parallax" data-velocity="-.3">
    <div class="row-fluid header">
        <div class="col-lg-6 col-sm-6 col-6 logo">
            <img src="img/logo.png" alt="" />
        </div>
        <div class="col-lg-6 col-sm-6 col-6 follow text-right">
            <a href="#"><img src="img/follow-fb.png" alt="Follow Us On Facebook" /></a>
            <a href="#"><img src="img/follow-tw.png" alt="Follow Us On Twitter" /></a>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-lg-12"> 
                <h1 class="text-center">Website Success</h1>
                <h2 class="text-center">Is Dependent On Effort and Imagination</h2>
                <p class="text-center"><a class="text-center can-do" href="#">See What We Can Do For You</a>
            </div>
        </div>
    </div>
</div>

I want to have more divs underneath the (.site-intro) not side by side. Then have links inside each div that will anchor to the next div.

4

1 回答 1

0

没有看到你的 DOM 很难说,但通常你可以只使用一个以逗号分隔的多元素选择器。

假设您要调整 3 个元素的大小:

  1. div与类site-intro
  2. div带身份证user-data
  3. section元素。

代码将如下所示:

function resizeDiv() {
    vpw = $(window).width();
    vph = $(window).height();
    $('.site-intro, #user-data, section').height(vph);
}
于 2013-09-09T21:50:50.207 回答