我有一个可调整大小的 div,它的内容超出了它的大小允许的范围。所以用户必须滚动浏览内容。当用户滚动或调整 div 大小时,我需要放置一个 float 标签,该标签停留在 div 内的一个位置。
<div id="pane1" class="ui-layout-center">Top</div>
<div id="pane2" class="ui-layout-south">
<span class="my_label">My Label</span>
A lot of content
</div>
这其实很像JSFiddle上的 float 标签,只是没有编辑器。我正在使用 jQuery UI 布局。
如何将我的标签保存在一个地方?
这是 JSFiddle 上的问题:http://jsfiddle.net/getvictor/hC6jP/2/
最佳答案
Fixed positioning ,或通过将标签放在 Pane 外进行绝对定位。
.my_label {
border: solid 2px #FF0000;
background: #fff;
display: block;
height: 22px;
position: fixed; // absolute -> fixed
margin-left:1em; // remove top/left positioning, and add left margin instead
// note: left is still easy to work with
}
关于javascript - 如何将标签保留在可调整大小和可滚动的 div 内的一个位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18283829/