我指定一个颜色十六进制代码作为一个非常长的 div 的 background-color
。但是,我希望这种颜色只在第一部分从左到右水平重复,而不是再往下。
可以使用 background-repeat:repeat-y
来完成还是有其他方法?
最佳答案
颜色没有高度……它们只是存在,没有维度。如果您希望在视觉上区分背景颜色和文档的其余部分,则需要使用纯色图像作为背景图像:
div.className {
background-image:url("images/background.jpg");
background-position:left top;
background-repeat:repeat-x; // Causes repeat from left-to-right only
}
关于css - 使用 CSS 使背景颜色仅在水平方向上重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/524965/