2015-03-31 55 views
-1

你知道如何讓一個div的高度是反應?在第一張照片是全屏模式,這是相當完美的。但是當我調整屏幕大小(在第二張圖片中)時,由於div數字「2」的高度,div數「1」和div數「3」之間有很大的空間。爲了您的信息,我正在使用引導程序。
這裏是我的div代碼:
DIV 1 = <div class="col-md-9 col-sm-9 col-xs-9" style="background-color:white;">
DIV 2 = <div class="col-md-3 col-sm-3 col-xs-3" align="middle" style="background-color:white;">
DIV 3 = <div class="row" style="background-color:white; bottom:0;" width="100%">
股利1和2區是一個DIV <div class="row" style="background-color:white;">
和所有的DIV在DIV <div class="container-fluid"

我想調整屏幕的大小時仍然像全屏模式一樣放置,沒有空間。 enter image description here如何使敏感div高度?

enter image description here

+0

如何爲你的圖像添加一個類'class =「img-responsive」'? – 2015-03-31 08:18:58

+0

可能的重複[使列在引導相同的高度](http://stackoverflow.com/questions/18227326/make-columns-the-same-height-in-bootstrap) – pbenard 2015-03-31 08:24:47

回答

0

的問題是,你的DIV號2是同一行中爲您的DIV編號1的他們都需要儘可能最高的人一樣高所以行。

爲了解決這個問題,你可以做一個行中的格數1列,並把DIV 1和DIV他們的列3

所以它看起來像這樣

<row> 
<col 1> 
<row> 
<col> 
div 1 here 
</col> 
</row> 
<row> 
<col> 
div 3 here 
</col> 
</row> 
</col1> 
<col 2> 
div 2 here 
</col 2> 
</row> 

這意味着然而,你的旗幟thingy只會傳播一半的屏幕。

+0

是否有另一種方式來我的橫幅在div 3仍然是全屏的寬度? – 2015-03-31 08:55:57

+0

我不知道。你可以垂直居中你的圖像,但是如果你使用GRID,我沒有辦法解決這個問題。你或者需要拉伸你的形象,這會讓它變得醜陋,或者讓左邊的字體變得很小。 – Robin 2015-03-31 08:58:58

0

如果您正在使用jQuery你可以做這樣的事情

$(window).on('resize', function() 
{ 
    // NOTE: You will need to give your divs ids. 
    // I have given div 1 id = "div-1" and div 2 id = "div-2" for the purpose of this answer. 
    var height = $('#div-1').height(); 
    $('#div-2').css('height', height); 
}); 

什麼,將要做的就是設置正確的股利左div的高度的高度,給他們同樣的高度。你也可以把字體大小和字母間距放在裏面。