2015-07-11 77 views
1

我奮力將圖像固定在一個彈出窗口,我的問題是圖像是越來越拉長到整個DIV,如何使圖像中心本身當DIV的大小增加

DIV的,我我正在申請從JQuery獲取寬度和高度。 HTML

<div id="portfolio-detail" style="width: 745px; height: 655px; top: 22px; display: block;"> 
    <img class="portfolio-close" src="assets/images/cancel-button.png"> 
    <div class="viewimg" style="position:relative;display:block;width:100%;height:100%;margin-left:auto;margin-right:auto;margin:0 ;"> 
     <img class="folioimg" style="position:absolute;width:100%" data-foliothumb="1" src="assets/gallery_crop_1.jpg">---&gt;</div> 
</div> 

的CSS是這樣的

.about-slider-container { 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    padding: 25px; 
    z-index: 100; 
} 

#portfolio-detail { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.9); 
    z-index: 9999; 
} 
+1

只是好奇。你的代碼如何與jquery相關? –

+0

當你說「拉伸」時,你的意思是它失去了寬高比嗎?而且,如果你想讓它伸展到可用的寬度,但仍保留這種寬高比?我會開始刪除高度屬性。 –

+0

@Vikram,你想以什麼樣的圖像爲中心圖像class =「folioimg」或class =「portfolio-close」 –

回答

1

嘗試將位置添加到您的。關於滑蓋容器。

.about-slider-container { 
    position: relative; //or something that suits you 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    padding: 25px; 
    z-index: 100; 
} 

#portfolio-detail { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.9); 
    z-index: 9999; 
}