2010-04-15 70 views

回答

2

这样的事情?

 body { 
      padding:0;margin:0; 
     } 
     #header { 
      position: absolute; 
      background: orange; 
      top:0; 
      left:0; 
      width: 100%; 
      height: 100px; 
     } 
     #footer { 
      position: absolute; 
      background: orange; 
      bottom: 0; 
      left: 0; 
      width: 100%; 
      height: 100px; 
     } 
     #middle { 
      position: absolute; 
      top: 100px; 
      bottom: 100px; 
      left: 0; 
      width: 100%; 
     } 
     img { 
      height:100%; 
      width: auto; 
     } 

<div id="header">header</div> 
<div id="middle"> 
    <img src="images/myImage.jpg" /> 
</div> 
<div id="footer">footer</div> 
+0

+1,但我会:1)使用CSS选择器'#middle img'或'#gallery img'而不是'img'; 2)使用'#middle {position:relative; margin:100px 0px;身高:100%;}'。 – ANeves 2010-04-15 17:17:22

+0

@sr pt:非常真实。这将是现实世界中不稳定的CSS。 – user113716 2010-04-15 17:21:17

+0

它完美的工作,谢谢你们两个 – ptinca 2010-04-15 20:55:14

1

使用#yourgallerydiv img { height: 100%; }(虽然width最好 - 我没有为height测试)为您的画廊格内的图像标签,以及大小大到足以填满一个大屏幕的深度,从而扩大时,他们不像素化图像。当父元素放大时(如果还有一个百分比),以百分比表示的图像会放大。

+0

我会考虑这一点,谢谢。 – ptinca 2010-04-15 21:04:01

相关问题