任何用jquery修复图像位置的方法

发布于 2024-09-01 00:58:24 字数 150 浏览 3 评论 0原文

我将图像放在特定位置,例如,

img {

position:absolute;
top:150px;

}

是否可以通过文本滚动来滚动图像,以便图像始终保持在相对于屏幕的相同位置。

我不想使用固定位置

I have the image at specific position e,g

img {

position:absolute;
top:150px;

}

Is there any to scroll the image with text scrolling so that image always stays at same position with respect to screen.

I don't want to use position fixed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那片花海 2024-09-08 00:58:24

您需要给它固定位置:

img {
  position:fixed;
  top:150px;
  left:200px;
}

然后相应地调整topleft值。

不需要 jQuery,但如果你仍然想要,你可以这样做:

$(function(){
  $('#img_id').css({
   position:'fixed',
   top:'150px',
   left: '200px'
  });
});

You need to give it fixed position:

img {
  position:fixed;
  top:150px;
  left:200px;
}

And then adjust the top and left values accordingly.

No need for jQuery but if you still want, you can do like:

$(function(){
  $('#img_id').css({
   position:'fixed',
   top:'150px',
   left: '200px'
  });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文