2017-09-27 66 views
0

我正在使用Accordion摺疊引導組件在頁面中顯示兩個摺疊項目。第一個摺疊項目默認摺疊,第二個摺疊項目中有一個顯示PDF文檔的iframe。我需要第二個可摺疊項目來適應屏幕的左側高度。我試圖用彈性盒來實現它,但似乎崩潰事件和彈出框有問題。我將不勝感激任何幫助。強制Iframe放入摺疊引導組件以適合屏幕

這是我的小提琴例如:

Example

下圖描述了不希望的行爲:
enter image description here

<vp-leftpanel> 
    <div class="panel-group" id="accordion" role="tablist" aria- 
     multiselectable="true"> 
     <div class="panel panel-default"> 
    <div class="panel-heading" role="tab" id="headingOne"> 
     <h4 class="panel-title"> 
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> 
       {{panelHeadingData}} 
      </a> 
     </h4> 
    </div> 
    <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> 
     <div class="panel-body"> 
      <div *ngIf="candidate.hasEmailSourceData"> 

       ..... 

      </div>     
     </div> 
    </div> 
</div> 
<div class="panel panel-default"> 
    <div class="panel-heading" role="tab" id="headingTwo"> 
     <div class="panel-title"> 
      <div class="row"> 
       <div class="col-md-6"> 
        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> 
         {{panelHeadingResume}} 
        </a> 
       </div> 
       <div class="col-md-6"> 
        <select class="form-control" (change)='loadDocument($event.target.value)'> 
         <option [value]="d.id" *ngFor="let d of candidate.candidateDocuments">{{d.friendlyName}}</option> 
        </select> 
       </div> 
      </div> 

     </div> 
    </div> 
    <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> 
     <div class="panel-body"> 
      <div *ngIf="candidate.candidateDocuments.length > 0" class="apply-flex"> 
       <iframe [src]="documentSelectedPathSafe" type="application/pdf" ></iframe> 
      </div> 
     </div> 
    </div> 
</div> 
    </div> 
    </vp-leftpanel> 
+0

其實,你的問題並不清楚你的需求是什麼。我嘗試過,並且非常好地工作你面臨什麼問題 –

+0

@GajendraSingh你的意思是工作絕對好。你能分享一下你嘗試過的嗎? –

回答

-1

只是max-height: 200px;更換CSS height=100%

+0

嗨!如果您在堆棧溢出中爲將來的工作簽出[回答問題格式](https://stackoverflow.com/help/how-to-answer)會更好。 - 謝謝 – Momin

+0

不幸的是,解決方案似乎比這更復雜。 –

+1

這不提供問題的答案。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/評論/低質量帖/ 17456566) – clemens

1

爲了使Flexbox具有一定的複雜性,

在這種fiddle demo我創建/應用下面的類來完成它,完全動態的,認爲這將打破手風琴的顯示/隱藏

.fullvh { 
    height: 100vh; 
} 
.flex-box-col { 
    display: flex; 
    flex-direction: column; 
} 
.flex-grow { 
    flex-grow: 1; 
} 
.pos-relative { 
    position: relative; 
} 
/* as it didn't work adding "flex-box-col flex-grow" to this 
    elements class, I added it using its ID #collapseTwo */ 
#collapseTwo {   
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
} 
.pos-absolute { 
    position: absolute; 
    height: 100%; 
    width: 100%; 
} 

的替代,在這個fiddle demo,不會打破手風琴,而不是給iframe一個高度結合視口單位vh和CSS calc()。即使固定高度160px在某種程度上是已知的,它仍然不如以前的樣本動態。

#collapseTwo iframe { 
    height: calc(100vh - 160px); 
    width: 100%; 
} 

另外,一個可在第一樣品中的修復腳本,或者在第二添加計算的腳本,以獲得精確的高度,或交換自舉4,其是基於Flexbox的。

交換到引導程序4可能無法解決問題,因此在開始遷移之前應對其進行徹底測試。

+1

感謝您的解決方案,真的很感激它。第一個肯定不適用於我需要的環境。第二個是一個很好的選擇,但我仍然不滿意固定的高度。我會等待看看是否有人提出另一個潛在的解決方案。現在我已經表決了你的答案。 –

+0

@D。B我已經介紹了3種可能的方式來做到這一點,而最好的兩種選擇是,恕我直言,擴大腳本實際檢測和設置高度,或使用Boostrap 4,這仍然可能需要一些調整。 – LGSon

+0

@ D.B我已經介紹了可用的選項,以便儘可能接近使用CSS單獨完成的工作。你覺得這個也夠被接受嗎? – LGSon