使iframe響應(yīng)當(dāng)我嘗試實現(xiàn)HTML和CSS以滿足我的需求時,我沒有相同的結(jié)果/成功。我創(chuàng)建了自己的JS小提琴,所以我可以告訴你它對我來說不起作用。我確定它與我正在使用的iFrame的類型有關(guān)(例如,產(chǎn)品圖像可能需要響應(yīng)或者其他什么?)我主要擔(dān)心的是,當(dāng)我的博客讀者在他們的iPhone上訪問我的博客時,我不希望所有內(nèi)容都是x寬度(我的所有內(nèi)容都是100%)然后iFrame行為異常并且是唯一更廣泛的元素(因此堅持超出所有其他內(nèi)容 - 如果這是有道理的??)無論如何,有誰知道為什么它不起作用?謝謝。這是MY JSFIDDLE的HTML和CSS(如果你不想點擊鏈接):<div class="wrapper">
<div class="h_iframe">
<!-- a transparent image is preferable -->
<img class="ratio" src="http://www.brightontheday.com/wp-content/uploads/2013/07/placeholder300.png" />
<iframe frameborder='0' height='465px' width='470px' scrolling='no' src='http://currentlyobsessed.me/api/v1/get_widget?wid=30&blog=Brighton+The+Day&widgetid=38585'
frameborder="0" allowfullscreen></iframe>
</div></div>這是附帶的CSS:.wrapper {
width: 100%;
height: 100%;
margin: 0 auto;
background: #ffffff;}.h_iframe {
position: relative;}.h_iframe .ratio {
display: block;
width: 100%;
height: auto;}.h_iframe iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;}
3 回答

滄海一幻覺
TA貢獻(xiàn)1824條經(jīng)驗 獲得超5個贊
我找到了Dave Rupert / Chris Coyier的解決方案。但是,我想讓卷軸可用,所以我想出了這個:
// HTML
<div class="myIframe"> <iframe> </iframe> </div>
// CSS
.myIframe { position: relative; padding-bottom: 65.25%; padding-top: 30px; height: 0; overflow: auto; -webkit-overflow-scrolling:touch; //<<--- THIS IS THE KEY border: solid black 1px;} .myIframe iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%;}
添加回答
舉報
0/150
提交
取消