如何在向下滚动时冻结上半部分?

时间:2014-02-23 21:18:26

标签: html css

嗨我可以冻结屏幕的上半部分:屏幕的第一行带有输入和按钮以及表格的第一个标题,因此滚动时两者都会冻结。

这是我要冻结的部分:

<input>input1</input>
<input>input2</input>
<button>A</button>
<button>B</button>
<button>C</button>
<button>D</button>
<table>
<tr><th>header1</th><th>header2</th><th>header3</th><th>header4</th><th>header5</th></tr>

请你在下面的jfiddle申请解决方案: http://jsfiddle.net/BRK2c/

3 个答案:

答案 0 :(得分:0)

您可以使用position:fixed作为演示节目:http://jsfiddle.net/BRK2c/4/

.upper{
    position: fixed;
    top: 0px;
    background: #c9c9c9;   
    display: block;

}

表格示例的标题滚动:http://jsfiddle.net/BRK2c/5/

答案 1 :(得分:0)

如果您希望该部分在滚动时保持静态,您可以将位置固定到该标记或向其添加一个类,然后定位该类

答案 2 :(得分:0)

这对你有什么帮助:

http://jsfiddle.net/gxRC9/76/

我用过

postion: fixed 

将它保存在一个地方,JQuery确保在滚动时使用这个固定位置。