html行内图片no-repeat,html - no-repeat makes image disappear - Stack Overflow

在html.net上学习CSS时,遇到一个问题:当尝试使用`background-repeat:no-repeat`属性设置背景图片不重复时,图片消失。示例代码中,背景图片在不使用no-repeat等属性时能正常显示,但一旦加上这些属性,所有海盗船背景图片都不见了。问题可能与CSS语法有关。
摘要由CSDN通过智能技术生成

I'm learning css and xhtml through a website called html.net. I'm following their instructions while working on my own website. I've just started the CSS tutorials on image background and i am encountering a small but annoying problem. When I do this, everything is fine. Meaning, there are pirate ships all over the place. It looks like the spanish armada.

body {

background-color: silver;

background-image: url("pix/pirateship.jpg")

}

h1 {font-size: 40px; font-family: arial; color:yellow; background-color:#0000a0;}

h2 {color:maroon;}

li {font-size: 20px; font-family: arial; color:#87f717; background-color:#34282c;}

table {color:black; background-color:gray;}

th {color:black;}

But... when i try and follow the next example, this is not showing any image at all.

body {

background-color: silver;

background-image: url("pix/pirateship.jpg")

background-repeat: no-repeat;

}

h1 {font-size: 40px; font-family: arial; color:yellow; background-color:#0000a0;}

h2 {color:maroon;}

li {font-size: 20px; font-family: arial; color:#87f717; background-color:#34282c;}

table {color:black; background-color:gray;}

th {color:black;}

I suspect this has something... actually, I don't know enough to start suspecting. I'm just gonna leave this one to you guys, and hopefully somebody knows the solution.

PS All of that is in a css file in the same folder as the index file. When I try and use any of the no-repeat, repeat-x or repeat-y values all of my pirates vamoose. The regular background image shows just fine when I don't use those.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值