【问题标题】:Footer pushes up to resize image in Content div页脚向上推以调整内容 div 中的图像大小
【发布时间】:2012-05-05 07:12:14
【问题描述】:

我正在尝试创建一个简单的布局,其中会有:

标题

内容(此处为图片)

页脚

我想要实现的是在内容 div 中放置一个图像,该图像将根据查看器的浏览器大小调整大小。

这部分我可以实现,但是我希望页脚始终保持在浏览器的底部,并让内容 div 中的图像调整大小而不会产生溢出。

这是我正在尝试做的一个示例: http://www.modernart.net/view.html?id=1,3,9

我已尝试复制此代码,但无法使其正常工作。 有没有人可以建议这样做的方法? 我会非常有帮助,因为到目前为止我还没有成功。

提前致谢, 高志

【问题讨论】:

  • 感谢 vascowhite。是的 - 正如我在发布我的问题时提到的那样,我已经从该站点复制了代码 - css 和 html。但是我不能让它适用于我的布局。我无法实现的主要部分是调整图像大小,因此不会创建滚动溢出,并且页脚始终位于图像下方的屏幕中。如果您能提出一种方法来做到这一点,我们将不胜感激。谢谢。
  • 您可以尝试使用粘滞页脚。谷歌的 CSS 粘性页脚。使用 @ 发送消息。
  • @Jawad。谢谢你的建议。我实际上已经尝试过了 - 但是图像只是在页脚下方结束。我基本上需要页脚始终位于 Bowser 的底部(与粘性页脚相同),但强制内容图像调整大小而不是创建溢出。
  • 我使用 Google Chrome 18.0.1025.168 作为我的浏览器和 MAC OS X 版本 10.6.8。

标签: html css resize liquid


【解决方案1】:

在 CSS 中使用百分比可能是一个解决方案:http://jsfiddle.net/rgv2e/

【讨论】:

    【解决方案2】:

    您确实应该尝试做事并从错误中学习。尽管如此,这是您所追求的布局:

    看到这个Working Fiddle Example!

    HTML

    <div id="header">My Beautiful website!</div>
    <div id="content">
      <a href="#" title="">
        <img src="http://i328.photobucket.com/albums/l330/slowwkidd3923/backflip.jpg" alt="ups...">
      </a>
    </div>
    <div id="footer">
      This is the footer text!
    </div>
    

    CSS

    /* basics */
    html, body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }
    
    /* header */
    #header {
        position: absolute;
        z-index:1;
        top: 10px;
        left: 10px;
    }
    
    /* content */
    #content {
        position: absolute;
        left: 0;
        right: 0;
        top: 10px;
        bottom: 20px;
        text-align: center;
    }
    #content img {
        height: 96%;
    }
    
    /* footer */
    #footer {
        position:absolute;
        bottom: 0;
        left: 10px;
        right: 10px;
        text-align: left;
        height: 20px;
        line-height: 20px;
    }
    

    帮助您学习 CSS 的链接:

    Cascading Style Sheets

    Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification

    MDN :: CSS - References, Tutorials and Demos

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-25
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多