我需要插入一个图像进行放大和缩小,但有些网站告诉我,它假设与path =“image url”一起使用。图像没有出现所以我想使用background-image:url(“image url”)。那我怎么把它放进去让图像显示出来呢?
<style type="text/css">
#html{
height:100%;
}
#body{
height:100%;
margin:0px;
padding:0px;
}
#hr{
border:0;
width:50%;
}
</style>
<body>
<div id="outerDiv0">
<div id="outerDiv" style="position:relative;height:99%;width:100%;border:1px solid black;overflow:hidden;">
<div style="position: absolute; top: 10px; left: 10px; z-index: 1">
<img src="zoomin_off.gif"
onclick="ZoomIn()" alt="zoomin"/>
</div>
<div style="position: absolute; top: 10px; left: 90px; z-index: 1">
<img src="zoomout_off.gif"
onclick="ZoomOut()" alt="zoomout"/>
</div>
<div id="Nav" style="display:none;position: absolute; top: 70px; left: 20px; z-index: 1"><div><a href="javascript:slidePrev();" id="slidePrev"><img src="prev.gif" alt="prev"/></a></div>
<div style="position: absolute; top: 0px; left: 79px;"><a href="javascript:slideNext();" id="slideNext"><img src="next.gif" alt="next"/></a></div></div>
<div id="imageTiles" style="position:relative;top:0;left:0;z-index:0;width:100%;"></div>
<div id="imageLabels" style="position:relative;top:0;left:0;z-index:1;width:900000px;height:900000px;"></div>
</div>
<div id="overlay"><div id="theScale"></div><div id="theInfo">
</div>
<div id="Thumb0"><div id="Thumb"></div><div id="Thumb2"></div></div>
</div>
<div id="wheelMode">Mouse Wheel:<input type="radio" onclick="wheelMode1()" /> Zoom<input type="radio" onclick="wheelMode2()" /> Next/Prev</div>
<div id="coords" style="position:absolute;top:2px;right:10px;z-index:10;"></div>
</div>
答案 0 :(得分:1)
没有任何示例代码,我们只能猜测。也许你的div没有任何尺寸。尝试使用css为您的div添加宽度和高度:
<div style="width:300px;height:300px;background:url('http://webpage/path/to/image.jpg')"></div>
答案 1 :(得分:0)
你能试试吗,
CSS:
.Bg{
width:300px;
height:300px;
background-image:url('imagepath');
}
HTML:
<div class='Bg'></div>
答案 2 :(得分:0)
很难理解你想要做什么,但是如果你想将背景图像添加到div,你可以按照以下方式进行操作
<div class="show">
some text
</div>
CSS中的
.show
{
background-image:url('paper.gif');
//other css properties of div
}