【问题标题】:Any way to fix the position of image任何固定图像位置的方法
【发布时间】:2010-05-10 20:10:30
【问题描述】:

我在左侧有一张图片,在右侧有文字。像两列布局。

我希望当我滚动文本时图像应保持在页面中心。

我尝试过使用

position:fixed

但是问题是,有时当我将 IE 窗口调整为小尺寸时,图像会停留在相同的位置,当我向下滚动时它会从主要内容区域出来。

我希望该图像应该滚动,但应该保持在内容区域内。它不应移出主要内容区域。

【问题讨论】:

  • 您是否有一些我们可以看到的源代码、与您的问题相关的 HTML 和 CSS,或者一个活生生的例子?

标签: javascript html css


【解决方案1】:
.content{ position: relative }
.image{ position: absolute; top: 0; left: 50%; }

<div class="content">
   <div class="image">
      <img src="image.jpg" />
   </div>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-28
    相关资源
    最近更新 更多