本地html不能显示本地图片
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
color: red;
width: 100px;
height: 100px;
background: url("6.png");
}
</style>
</head>
<body>
<div>
哈哈
</div>
</body>
</html>
图片不论是绝对路径还是相对路径都不行,vs code和浏览器都不报错
请帮帮我{:10_277:}
加个background_size就好了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
color: red;
width: 100px;
height: 100px;
background-image: url("6.png");
background-size: 100px 100px;
}
</style>
</head>
<body>
<div>
哈哈
</div>
</body>
</html> xiaosi4081 发表于 2021-7-21 16:37
加个background_size就好了
大佬厉害{:10_279:} ftwegc 发表于 2021-7-21 17:02
大佬厉害
我也是突然想到,图片总得有个尺寸吧 还是可以
页:
[1]