css - 自定义背景图片

标签 css background

如何在 css 中创建这样的背景(中间和最后一个 block 具有流体高度):

bg

有什么好的教程吗?

最佳答案

您可以制作顶部和底部的 div 元素并按如下方式设置它们的 CSS:

#topBGDiv 
{
    width: 100%;
    height: 125px; // Make this the height of the background image in pixels
    background-image: url('dark-gray-ribbon.jpg');
    background-repeat: repeat-x;
    overflow: hidden;
}


#bottomBGDiv 
{
    width: 100%;
    height: 110px; // Make this the height of the background image in pixels
    background-image: url('light-gray-ribbon.jpg');
    background-repeat: repeat-x;
    overflow: hidden;
}

使用像这样的图像作为顶部的背景图像:

enter image description here

底部是这样的:

enter image description here

最后,将页面背景色的 CSS 设置为中间色。所以,像这样:

body
{
    background-color: #C0C0C0;
}

关于css - 自定义背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11207947/

相关文章:

c++ - QT背景图片

css - 流体布局背景 100% 宽,每边 50px 填充

css - 多个背景图像 - 无法将图像置于前面

html - 如何在 ionic 工具栏的中心设置和对齐 ionic 选择

html - CSS: header bg 图片位置

java - Android:最小化应用程序并显示图标

html - CSS3 动画延迟问题

CSS 子菜单不出现 : Probably z-index issue

jquery slider 改变 body 背景

html - 悬停按钮图像不适合所有菜单?