html - 将背景图像添加到 div(动态内容)

标签 html css

我有一个 DIV ...

<div id="content">

</div>

现在...在设计中,如果您认为它是一个矩形,顶部作为页眉,页脚也不同,那么我不能只创建一个 1px 背景图像并重复它。

我必须做类似的事情:

<div id="content">
<div id="header">This will have a fixed bg image</div>
<div id="body-content">This will have a repeated bg image and it's the part that can grow.</div>
<div id="footer-content">THis will content a fixed bg image for the footer</div>
</div>

谁能建议最好的方法来明智地处理这种设计 CSS?

最佳答案

#header
{
   background-image: url('header.png');
   background-repeat: no-repeat;
}

#body
{
   background-image: url('body.png');
   background-repeat: repeat-y;
}

#footer
{
   background-image: url('footer.png');
   background-repeat: no-repeat;
}

关于html - 将背景图像添加到 div(动态内容),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6094952/

相关文章:

javascript - Jquery + GSAP 从 onComplete 函数访问本地计算的值

jquery - 依赖下拉列表仅适用于表中的单行

html - <hx> 标签后的文本未移至新行

html - 为什么我的输入在右侧有填充?

java - 将 AmCharts 导出为 PNG、JPG 等

html - 如何在页脚中显示垂直白色边框?

javascript - 如何通过 JavaScript 重新触发 WebKit CSS 动画?

javascript - Safari 在请求带有下载 header 的链接时停止 jquery 动画

html - 为什么我的页面元素在页面加载时都是从左上角进来的?

html - 如何覆盖 Bootstrap 样式