2016-09-26 33 views

回答

3

这里是我用于响应式堆叠divs的方法。

这将适用于您要求的两种方法,但我建议您不要向移动用户加载桌面版本,但出于带宽的考虑,他们无法阻止加载内容。

它基于百分比和我的经验,它具有最佳的响应结果,最少的编码。一旦您替换照片,您需要调整CSS中的宽度和高度百分比值以根据需要进行缩放。

标记

<div id="container"> 
     <div id="photo"> 
     <img src="https://d3nj7353mvgauu.cloudfront.net/media/categories/iphone-6-6s-6-plus-6s-plus-1.png" width="100%" height="auto"> 
      <div id="site"> 
      <iframe src="https://www.godaddy.com/" width="99%" height="99%"></iframe> 
      </div> 
     </div> 
    </div> 

的CSS

#container { 
    position: relative; 
    width: 100%; 
    max-width: 600px; 
    height: auto; 
} 

#photo { 
    position: absolute; 
    width: 100%; 
} 

#site { 
    position: absolute; 
    width: 100%; 
    max-width: 43%; 
    height: 76%; 
    top: 11.75%; 
    left: 28.25%; 
    border: none; 
} 

的jsfiddle Demo Link

相关问题