+ -
当前位置:首页 → 问答吧 → 为什么列表项li的背景图片显示不出来呢

为什么列表项li的背景图片显示不出来呢

时间:2010-07-24

来源:互联网

如题,在浏览器里列表项li的背景图不能显示,是怎么回事?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body {
  background-image: url(image/WALLPAPER_FILE1024_200872817019.jpg);
  background-repeat: no-repeat;
  background-position:center 0;
}
ul li {
  /*line-height: 200%;*/
  display: inline;
  background:transparent url(image/anniuchugaoj.jpg) no-repeat 0 0;
  padding:0 0 0 0;
}
ul {
  list-style-type: none;
  margin-top: 55px;
  padding:0;
  width:760px;
  left: 260px;
  top: 10px;
  margin-bottom: 10px;
  position: fixed; /*margin-left: 250px;*/
}
</style>
</head>

<body>
<ul id="daohang">
<li>美食天地</li>
<li>爱优惠</li>
<li>关于我们</li>
<li>网友问题</li>
</body>
</html>

作者: loliah   发布时间: 2010-07-24

可以显示,ie8,ff.oprea测试正常
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body {
  background-image: url(image/WALLPAPER_FILE1024_200872817019.jpg);
  background-repeat: no-repeat;
  background-position:center 0;
}
ul li {
  /*line-height: 200%;*/
  display: inline;
  background:transparent url(http://dotnet.aspx.cc/images/rss.gif) no-repeat 0 0;
  padding:0 0 0 16px;
}
ul {
  list-style-type: none;
  margin-top: 55px;
  padding:0;
  width:760px;
  left: 260px;
  top: 10px;
  margin-bottom: 10px;
  position: fixed; /*margin-left: 250px;*/
}
</style>
</head>

<body>
<ul id="daohang">
<li>美食天地</li>
<li>爱优惠</li>
<li>关于我们</li>
<li>网友问题</li>
</body>
</html>

作者: net_lover   发布时间: 2010-07-24

ul li {
  /*line-height: 200%;*/
  display:block;
  background:transparent url(image/anniuchugaoj.jpg) no-repeat 0 0;
  padding:0 0 0 0;
}

试试!

作者: a89359511   发布时间: 2010-07-24

还是没用啊,文字列表项仍然是白色背景,我的背景图片可是红色的。

作者: loliah   发布时间: 2010-07-25

确定你的url是否正确啊!

作者: huangyunzeng2008   发布时间: 2010-07-25

url是对的

作者: loliah   发布时间: 2010-07-25

楼主你的 UL 没有闭合

作者: WebAdvocate   发布时间: 2010-07-26

测试了可以显示啊,LZ你掉了个UL

作者: emily1900   发布时间: 2010-07-26

你们用的是自己的图片吗? 图片尺寸多大?什么格式的?

作者: loliah   发布时间: 2010-07-26

先用背景色看看

作者: chenyuzou   发布时间: 2010-07-27

背景图片是要设置它的宽度和高度的……

作者: richel1314   发布时间: 2010-07-27

引用 10 楼 richel1314 的回复:
背景图片是要设置它的宽度和高度的……


我这段代码应该怎么改?

作者: loliah   发布时间: 2010-07-27

没人知道吗??

作者: loliah   发布时间: 2010-07-28

IE和 Firefox里的显示效果不一样哦

作者: loliah   发布时间: 2010-07-28

引用 13 楼 loliah 的回复:
IE和 Firefox里的显示效果不一样哦



ul 
{
  margin-left:0;
  padding-left:0;
}

作者: sharpblade   发布时间: 2010-07-28

正常列表效果正常,为什么设置了display: inline;后, li的背景图像变得又细又窄了呢?

作者: loliah   发布时间: 2010-07-29

????

作者: loliah   发布时间: 2010-07-31

IE和 Firefox里的显示效果不一样哦

作者: LAWHK368   发布时间: 2010-07-31

引用 17 楼 lawhk368 的回复:
IE和 Firefox里的显示效果不一样哦


设置了display: inline后,2个浏览器里都很难看的,

难道导航列表横向以后,li的背景图片就变成这样了呢?

作者: loliah   发布时间: 2010-08-01

图片的文件名不能有中文,否则显示不出来!!

作者: SugarChen2011   发布时间: 2011-10-23