我正在爲應用程序開發一種視覺模擬器。如何在html中將div附加到特定維度
這裏是我想什麼:
上面的影像是一個iphone線框。我想在iphone屏幕的邊界內插入一個div或任何其他元素。
我搜索了iframe。但html5不支持滾動視圖。所以我正在尋找一種方式來做另一種方式。
我使用引導程序3並希望它是響應(FYI)。
編輯 所以,我想Soviut的回答是:
這是我的HTML的一部分:
<div id="page" class="row">
<div id="iOS" class="col-md-6">
<div id="iphone-wireframe" class="container">
<div class="content">
<h1>This is heading</h1>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
<p>This is some content This is some content This is some content This is some content This is some
content This is some content This is some content This is some content.</p>
</div>
</div>
</div>
我還調整了CSS,使之更適應用百分比等,並通過模仿img響應的特點。我的CSS的
部分:
.container {
width: 65%;
height: 90%;
margin-top: 40px;
background-image: url("/assets/res/img/iPhone-wireframe.png");
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
.content {
margin: 81px auto auto;
width: 67.5%;
height: 75.5%;
background: #FFF;
overflow: auto;
}
結果是完美的,當它被調整了。它也具有響應能力,但圖像和文本無法同步響應。我不知道如何用言語解釋這個所以我就用圖片顯示:
任何示例代碼?你有什麼嘗試?我們不會爲你編碼,如果你嘗試了這個,發佈你的嘗試 –
我確實提到過我認爲iframe和根據w3schools文檔它不支持HTML 5中的滾動。我不問任何人給我代碼爲此,我只是要求正確方向的指針或想法。如果你確實感覺到了,我會編輯我的問題。 – GauravPandey
@AdamBuchananSmith:在Soviut的回答幫助下,我試圖更新我的問題。 – GauravPandey