HTML - body 背景图片重复

3

正如您在此页面中所看到的 - http://www.white-cell.com/events.htm - 在底部,由于文本过长,背景图像会重复。 与此相关的行是:

<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" background="images/bg_wide.gif">

谢谢!

2个回答

11

使用CSS来指定你的背景图片(background 已经非常过时),并关闭重复功能。

将以下代码放置于你的 head 部分:

<style type="text/css">
body
 {
     background-image: url(images/bg_wide.gif);
     background-repeat: no-repeat;
 }
 </style>

还有一种属性可以设置背景图片的位置(background-position)。

了解更多关于定义背景的信息,请访问w3schools


2
您可以使用此样式来防止图片重复出现:

background-repeat: no-repeat;

body {
  background:url(images/bg_wide.gif) no-repeat;
}
no-repeat表示不重复图片。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接