html - x-repeating 背景图像未完全展开

标签 html css background background-image background-repeat

我现在花了几个小时尝试不同的事情来弄清楚如何在 css 中获取 2 个背景图像以扩展页面的整个宽度。

网站在这里:http://res-intel.com

我知道在#main 中定义宽度不会让它展开。但是我想不出解决办法。我认为 body 应该工作!我能做什么?

非常感谢!

相关的CSS代码是:

body {
background-image:url('http://res-intel.com/images/headerbg.jpg') repeat-x top right;
margin:auto;
padding:0;
text-align: center;
font-family:arial;
}

#main {
background: url('http://res-intel.com/images/contentbg.jpg');
background-repeat:repeat-x;
width:904px; 
text-align:left;
}

最佳答案

你有语法错误。您不能为背景图像添加 repeat-x 和位置属性。您需要使用 like background 而不是 background-image。像下面这样更新您的 CSS。

 body {
  background:url('http://res-intel.com/images/headerbg.jpg') repeat-x top right;
  margin:auto;
  padding:0;
  text-align: center;
  font-family:arial;
 }

关于html - x-repeating 背景图像未完全展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24273856/

相关文章:

javascript - 当字段值无效时表单提交

android - 在 cordova/phonegap 应用程序中设置横向 View 的问题

php - 图像隐藏在 mpdf8 中的内容后面

html - 如何根据div的高度将文本分成多行并在末尾添加省略号?

html - 为什么有这么多文本从 flexbox 对齐的内容中溢出?

javascript - CSS 根据另一个元素设置颜色

java - 处理中:启动画面背景错误

css - 使用 CSS 变量定义 -webkit-background-clip 属性在 Chrome 上不起作用

css - 制作多个背景图像的最佳方式?

html - 每个表行的 anchor