html - 如何在响应式 div 中调整模拟智能手机屏幕的大小?

标签 html css iframe responsive-design

因此,我试图在一个 div 中展示一个移动网站,该网站看起来像放置在响应式 html5 网站上的智能手机。我弄乱了 CSS,以便智能手机 div 在调整窗口宽度时保持稳定的纵横比。现在我试图在 div 中安装一个 iframe 来模拟手机的屏幕。 我遇到的问题是我的响应式 CSS 技巧弄乱了屏幕的位置。

这是一个 jFiddle:http://jsfiddle.net/E6X4j/2/

我试图将它定位为相对位置,但这会扰乱 CSS 中的响应技巧。有什么建议吗?

HTML:

<div id="smartphonewidth">
<div id="smartphoneheight">
    <object type="text/html" data="http://www.engadget.com" style="width:100%; height:100%;">    
    </object>
</div>

CSS:

#smartphonewidth {
      margin-left: 5%;
      background-image: url('http://i.imgur.com/lavEp8B.png?1?5267');
      background-repeat: no-repeat;
      width: 50%;
      padding: 20%;
      background-size: 100% 100%;}

#smartphoneheight {
    position: absolute;}

最佳答案

使用此链接 CSS3 media queries for reponsive design

要定位小型设备,我们可以使用以下语法:

@media only screen and (max-device-width: 480px) {
          //your css here
    }

请检查这个JSFIDDLE

CSS:

#smartphonewidth {
          margin-left: 5%;
          background-image: url('http://i.imgur.com/lavEp8B.png?1?5267');
          background-repeat: no-repeat;
          width: 50%;
          padding: 20%;
          background-size: 100% 100%;

}

#smartphoneheight {
    position: relative;
    z-index:1;
    width:100%;
    height:100%;
}

关于html - 如何在响应式 div 中调整模拟智能手机屏幕的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20811557/

相关文章:

javascript - 根据按下的按钮显示 div

api - YouTube iFrame API 质量参数 "vq"bug - 黑屏视频播放

jquery - 最初隐藏的 iframe 在刷新之前不会正确加载。我该如何修复?

css - 中心对齐工作一次然后中断

html - 为我的网站 CSS 相关修复 Google Chrome 错误

html - 将按钮放置在将成为 map 的 png 上的最佳方法

html - iframe 到无穷大

html - 去除html页面中的颜色

CSS 属性自动换行不适用于 Firefox 上的 select 元素

html - 将鼠标悬停拇指效果从缩小更改为放大