使div垂直固定,但水平粘贴到页面的边框

Fit*_*Dev 3 html css positioning fixed

您能否请访问:http://www.binarymark.com/Products/ColorPickerPro/default.aspx并注意页面的布局.

我想要做的是将一些小div粘贴或"粘合"到页面的右侧,这样它就在页面的右边框之外.

但是,垂直方式我想将div固定到一个Window,无论页面滚动多少,它都应该保持距窗口顶边300px的固定位置.

这是它应该是什么样子http://www.binarymark.com/layexp.png

你能帮我吗?

看起来很简单,但我不知道如何组合垂直固定定位和水平相对/绝对定位,并确保它支持所有主流浏览器.

谢谢.

Mat*_*all 7

position: fixed;
right: 0;
top: 50%;
Run Code Online (Sandbox Code Playgroud)

编辑:尝试插入此div作为您的第一个孩子<div id="content">...

<div class="right-tab">TEXT</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.right-tab {
    position: fixed;
    top: 50%;
    width: 1100px;
    background-color: red;
    text-align: right;
}
Run Code Online (Sandbox Code Playgroud)

这应该让你开始.宽度将指定您希望选项卡显示的内容超过多少(因此在这种情况下,它大约为100 px).红色背景只是让你可以更容易地看到div.

  • 没问题.其他人的工作比我自己的工作更有趣! (2认同)