日期:2014-05-17  浏览次数:20586 次

div中的背景图片如何精确定位
如题,如果要设置背景图片从图片的左边10px上方20px处开始显示,该怎么做?

代码
-----------------------------
<style   type= "text/css ">
.dv{
    width:   100px;
    height:   200px;
    background:   url(1.gif);
}
</style>
<body>
<div   class= "dv ">  
</div>
</body>

------解决方案--------------------
五分也要挣上.

.dv{
width: 100px;
height: 200px;
background: url(1.gif);
/* background-position:12%,20% 这样也可以 */
background-position:30px,40px;
}