【问题标题】:iphone silhouette with scrolling image inside带有滚动图像的 iphone 剪影
【发布时间】:2014-11-16 11:02:00
【问题描述】:

我正在尝试制作一个带有滚动图像的 iphone 叠加层,以展示移动网站设计,但图像没有滚动,上面覆盖的 iphone 是我做错了什么,我该如何解决?

演示: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>

【问题讨论】:

  • 我正在尝试编辑您的示例,但是像 jsfiddle 这样的接缝在我的机器上无法正常工作...无论如何,iphone 应该有一个相对位置和一个 z-index:-1 (以便上面的图像完全可用)并且上面的图像应该具有与父级(iphone)相关的绝对位置和合理的边距

标签: html css iphone image overlay


【解决方案1】:

我已经对您的示例进行了分叉并对其进行了一些调整。通过将内部内容保持在恒定宽度,我们可以垂直扩展其容器,效果就像我们只将滚动条向右移动一样。另请注意,我们可以为 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>

最好的问候

【讨论】:

    【解决方案2】:

    您可以像这样构建您的 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多