开发者

Mapping a dot over an image

I have this gif image, but i want to place a dot on 261,274 on that image. The dot is 7px by 7px. How can i do this? I have tried this:

<table style="background: url('mainimage.gif'); width:513px; height:550px;">
    <tr>
        <开发者_开发技巧;td style="position:relative; top:274px; left:-261px; background: url('dot.gif'); width:7px; height:7px;"></td>
    </tr>   
</table>

And this:

<div style="background: url('mainimage.gif'); width:513px; height:550px;">
    <div style="position:relative; top:274px; left:-261px; background: url('dot.gif'); width:7px; height:7px;"></div>
</div>

But those doesn't seem to work properly.

I have also looked at the area element, but i can't realy figure out how to work with those.

EDIT: Jsfiddle's:

http://jsfiddle.net/3Ahfd/

http://jsfiddle.net/3Ahfd/1/


Try this:

<div style="background: url('mainimage.gif'); width:513px; height:550px;position:relative;">
    <div style="position:absolute; top:271px; left:259px; background: url('dot.gif'); width:7px; height:7px;"></div>
</div>

Note: adjust top and left of the inner div accordingly - I subtracted 3px from your coordinates to center the dot.


Use relative positionioning. There you go:

<div style="background: url('mainimage.gif'); width:550px; height:513px; position: relative;">
    <img src="dot.gif" style="position: relative; top:264px; left:258px; width:7px; height:7px;">
</div>

Fiddle: http://jsfiddle.net/alp82/3Ahfd/6/


<div style="background: url('mainimage.gif'); width:513px; height:550px; position:relative;">
    <div style="position:absolute; top:274px; left:261px; background: url('dot.gif'); width:7px; height:7px;"></div>
</div>

JSFiddle.


Instead of making the dot a background image of a div, I'd suggest just using it as an image tag and positioning it accordingly using margins.

Something like:

<div style="background: url('mainimage.gif'); width:513px; height:550px;">
    <img src="dot.gif" style="margin-top:274px; margin-left:-261px;" />
</div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜