2014-09-11 77 views
0

我有一個問題,我使用的是一個調整div的負載的佈局工具。這些div具有標題範圍,其設置爲bottom : 0。在縮短的div上,這些都很好,但是在延長的DIV上,這些浮動在div的底部之上。得到呈現DIV高度

我已經嘗試過各種CSS方法,使跨度堅持到底部,但似乎一旦這個呈現,然後freewall(佈局腳本)有它的方式,跨度不會被推回。

我試圖通過各種方法獲得父DIV的高度。當我控制檯登錄div時,我可以看到它的高度在element.style(height:222.4px);但是當我嘗試訪問樣式時,它只返回css應用的背景圖像,而不是渲染的高度。任何通過jquery.height()的嘗試只會返回不正確的CSS高度(200px)。

任何想法如何確保一個元素在佈局調整大小後保持底部,或者訪問渲染高度的方式,以便可以通過編程方式將其粘貼回底部?

這裏是CSS

.guideScene 
{ 
    height :   200px; 
    width :    200px; 
    min-width :   190px; 
    background-size: cover; 
    background-repeat: no-repeat; 
    background-position: center; 
    position:   absolute; 

} 


@media all and (max-width: 768px) { 
    .guideScene { 
     height :  100px; 
    } 
} 

.guideScene span 
{ 
    font-family:  'Lato', sans-serif; 
    font-color :  #000; 
    font-weight:  700; 
    font-size:   14px; 
    line-height:  100%; 
    min-height:   14px; 
    background:   #fff; 
    padding:   4px 10px 4px 10px; 
    bottom:    0px; 
    width:    100%; 
    position:   absolute; 

} 

在這裏你去popNoodles:

 console.log($(this.parentNode).outerHeight(true)); 
     console.log($(this.parentNode).height()); 

console.log($(this.parentNode).attr('style') - 返回後臺

 console.log(this.parentElement) gives me the data 

正是這種屬性在這裏我想訪問!

enter image description here

+1

請同時發佈足夠的HTML內容,以便輕鬆地複製。 – Popnoodles 2014-09-11 00:27:47

+0

此外,你已經標記了這是一個JavaScript jQuery的問題,提到了你嘗試過的一些jQuery,但沒有顯示任何JavaScript或jQuery。 – Popnoodles 2014-09-11 00:28:38

回答

1

.height()只是給元素高度

.innerHeight()給人的元素高度加上頂部/底部填充

.outerHeight(true)可能是你正在尋找的,因爲它給元素高度的東西,頂部/底部填充和邊框加上它會添加邊距,如果設置爲true

+0

謝謝。 $(this.parentNode).outerHeight(true)返回200,和以前一樣。 – user5839 2014-09-11 01:18:20

+0

其實這個工作,我稱它爲時尚早。謝謝 – user5839 2014-09-11 02:12:47