我正在尝试制作一个带有滚动图像的iphone覆盖图来展示移动网站设计,但图像不是滚动覆盖的iphone在顶部是否有我做错了什么以及我该如何修复它? / p>
DEMO:http://jsfiddle.net/jonathanl5660/Lao36z20/
<div>
<img src="https://dl.dropboxusercontent.com/u/9833562/iphone.png" width="370px" height="800px" style="position: absolute; ">
</div>
<div style="width:300px;height:700px;overflow:scroll;margin:30px; position: relitive;">
<img src="https://dl.dropboxusercontent.com/u/9833562/mtest.png" width="98%" height="700px" alt="" style="margin-top:150px;margin-left:10px;" /><br />
<br />
</div>
答案 0 :(得分:1)
你可以像这样构建你的HTML:
<div class="iphone">
<div class="container">
<img src="https://dl.dropboxusercontent.com/u/9833562/mtest.png" alt=""/>
</div>
</div>
然后用CSS调整外观:
.iphone {
width:370px;
height:800px;
background:url('https://dl.dropboxusercontent.com/u/9833562/iphone.png') no-repeat center;
background-size:100%;
}
.container {
position:relative;
top:152px;
width:293px;
margin:auto;
max-height:496px;
overflow:auto;
}
.container img {
width:100%;
}
选中 demo Fiddle
答案 1 :(得分:0)
我已经把你的例子分开并稍微扯了一下。通过将内部内容保持在恒定宽度,我们可以垂直扩展其容器,效果就像我们只将滚动条向右移动一样。还请注意我们可以为x和y轴设置溢出行为。
这是JSFiddle链接:
http://jsfiddle.net/74yh81s4/2/
和代码:
<div class="position: relative">
<img src="https://dl.dropboxusercontent.com/u/9833562/iphone.png" width="370px" height="800px">
</div>
<div style="width:340px; height:472px; overflow-x:hidden; overflow-y:scroll; margin:30px; position: absolute; top: 142px; left: 17px">
<img src="https://dl.dropboxusercontent.com/u/9833562/mtest.png" width="295px" alt="" />
</div>
祝你好运