admin管理员组文章数量:1026989
My webpage has a large image (a map). I want to position, at the top right of the image, a small icon that is for closing the map.
How can I figure out the position and place the image appropriately?
The image has a fixed width of 900 x 600.
I have jquery on the page if that helps.
I tried using $("#map").position and I have the top and left, but not sure how to position to the top right.
My webpage has a large image (a map). I want to position, at the top right of the image, a small icon that is for closing the map.
How can I figure out the position and place the image appropriately?
The image has a fixed width of 900 x 600.
I have jquery on the page if that helps.
I tried using $("#map").position and I have the top and left, but not sure how to position to the top right.
Share Improve this question asked May 25, 2010 at 15:11 BlankmanBlankman 268k332 gold badges797 silver badges1.2k bronze badges 02 Answers
Reset to default 7The easiest way would just to positon the close button absolutely with CSS instead of calculating the positon with JS. For example:
<div id="map" style="position: relative;">
<img src="yourmap.png">
<img src="close.png" style="position: absolute; top: 0; right: 0;">
</div>
You could also take a look at the latest jQuery-UI bits. They have some facilities for positioning elements relative to other elements on the page. Depending on what browsers your wanting to support this could be simpler than creating the browser-agnostic CSS.
My webpage has a large image (a map). I want to position, at the top right of the image, a small icon that is for closing the map.
How can I figure out the position and place the image appropriately?
The image has a fixed width of 900 x 600.
I have jquery on the page if that helps.
I tried using $("#map").position and I have the top and left, but not sure how to position to the top right.
My webpage has a large image (a map). I want to position, at the top right of the image, a small icon that is for closing the map.
How can I figure out the position and place the image appropriately?
The image has a fixed width of 900 x 600.
I have jquery on the page if that helps.
I tried using $("#map").position and I have the top and left, but not sure how to position to the top right.
Share Improve this question asked May 25, 2010 at 15:11 BlankmanBlankman 268k332 gold badges797 silver badges1.2k bronze badges 02 Answers
Reset to default 7The easiest way would just to positon the close button absolutely with CSS instead of calculating the positon with JS. For example:
<div id="map" style="position: relative;">
<img src="yourmap.png">
<img src="close.png" style="position: absolute; top: 0; right: 0;">
</div>
You could also take a look at the latest jQuery-UI bits. They have some facilities for positioning elements relative to other elements on the page. Depending on what browsers your wanting to support this could be simpler than creating the browser-agnostic CSS.
本文标签: JavaScriptJQueryposition 39close icon39 div in the top right of a large imageStack Overflow
版权声明:本文标题:javascript - jquery, position 'close icon' div in the top right of a large image - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745468782a2152013.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论