开发者

Scale div in an upwards direction, instead of down?

开发者 https://www.devze.com 2023-01-03 01:03 出处:网络
I have a custom info window over a google map, sometimes these info windows contain an image. When they do, the info window scales down over the marker it is positioned over as soon as the image has f

I have a custom info window over a google map, sometimes these info windows contain an image. When they do, the info window scales down over the marker it is positioned over as soon as the image has finished loading.

So the images take longer to load and the div's position has already been calculated by the time the image is finished loading.

I do believe there is a way开发者_如何学Python of checking if an image has finished loaded, but that seems a long route - is there not a simple way with JS or CSS to get the div to scale upwards instead of down.

Anyone have any clues?


Use absolute positioning and instead of setting the offset with top use bottom. With this property you can ensure the position of the bottom edge of your div - any change in size will force the div to expand upwards.


or try this (it can also be useful to set an anchor)

<div style="position: absolute;">
  <div style="margin-top: calc(-70vh + 40px);"><a id="update">my image</a></div>
</div>
0

精彩评论

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