background-image图片不显示问题
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>轮播图</title> <link rel="stylesheet" type="text/css" href="css/Carousel.css"> <link rel="stylesheet" type="text/js" href="css/Carousel.js"> </head> <body> <div class="container"> <div class="nav"> <ul> <li>首页</li> <li>点击查看</li> <li>会自动的</li> <li>我的网站</li> </ul> </div> <div class="banner"> <a href=""> <div class="pic-one"></div> </a> <a href=""> <div class="pic-two"></div> </a> <a href=""> <div class="pic-three"></div> </a> <a href=""> <div class="pic-four"></div> </a> </div> </div> </body> </html>
*{
padding:0;
margin:0;
}
.container{
width:1000px;
height:600px;
margin:0 auto;
border:1px solid black;
}
.nav{
width:1000px;
height:50px;
font-size: 30px;
}
.banner{
width:1000px;
height:550px;
}
li{
display: inline-block;
}
.pic-one{
background-image:url(../img/1.jpg) no-repeat;
}
.pic-two{
background-image:url(../img/3.jpg) no-repeat;
}
.pic-three{
background-image:url(../img/4.jpg) no-repeat;
}
.pic-four{
background-image:url(../img/5.jpg) no-repeat;
}老师老师,为什么图片显示不出来呀,路径没有错呀
26
收起
正在回答
2回答
1.如下图所示:你的书写方式不正确:

正确书写方式应该是:background:url(‘../img/1.jpg’) no-repeat;
2.需要给设置背景图片的div指定height
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星