css - 替代主体和页脚之间间距的百分比边距?

标签 css

我创建了一个固定在页面底部的页脚,但问题是它紧跟在我最后一张图片之后,所以它们之间没有间距。我想在最后一张图片和页脚之间留出空间,所以我认为创建基于 % 的边距是一个很好的解决方案。但是,我不得不使用 margin-bottom:180%,这对我来说似乎很草率,并且在调整窗口大小时会出现问题。我的代码本质上是(删除了额外的图像以防止困惑):

<body>
<div id='wrapper'>
<section class='gallery-set'>
<div class='wrap'>
    <img class='tilesetsmall' src ='images/sample.jpg'/>
  <div class='ontop'><p class='example-text'>Overlay Test text </p></div>
</div>
</section>
</div>
<div id="footer">
</div>
</body>

所以我的目标是在页脚和其余内容之间创建一个空间。

最佳答案

如果您不介意静态,请尝试使用px。如果你想更动态一点,尝试使用 em

margin-bottom: 30px;
margin-bottom: 5em;

http://www.w3schools.com/cssref/css_units.asp

 1em is equal to the current font size. 2em means 2 times the size of the current font.
 E.g., if an element is displayed with a font of 12 pt, then '2em' is 24 pt. The 'em' is a
 very useful unit in CSS, since it can adapt automatically to the font that the reader uses

关于css - 替代主体和页脚之间间距的百分比边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25006759/

相关文章:

html - CSS 水平菜单 - 为什么仅在 IE 中有 1px 的边框/空间?

html - chrome和firefox定位不同

html - 圆 Angular div显示较小尺寸的边缘

javascript - jquery 媒体查询上的 jQuery 侧边导航

css - 使用 CSS 强制侧边栏高度 100%(带有粘性底部图像)?

css - 使我的图像和脚本响应

javascript - Bootstrap Dropdown 永久显示 - 不特定于按钮点击

html - 如何设置DIV使页面垂直适合屏幕?

javascript - 调整 div 大小以适合屏幕

android - 英特尔 xdk jquery css 不工作