-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path吸顶js实现.js
96 lines (73 loc) · 2.37 KB
/
吸顶js实现.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
class Head extends React.Component {
constructor(props) {
super(props);
this.state = {
contentClass:"conditionArea" //
};
this.windowOnScroll(); //
let isScrollTop = true; //
};
// windowOnScroll(){
// let _this = this;
// window.onscroll = function(){
// //获取滚动条滚动的距离
// let h = document.body.scrollTop;
// console.log(h);
// if(h > 74){
// console.log('111');
// _this.setState({
// contentClass:"conditionArea conditionArea_fixed"
// });
// }else{
// _this.setState({
// contentClass:"conditionArea"
// });
// }
// }
// };
render() {
return (
<div className="container">
<div className="set_head_fixed">
<span className="set_text">我是头部</span>
</div>
// <div id="conditionArea" className={this.state.contentClass}>
<div className="content_name">
<span>置顶块</span>
</div>
</div>
<div className="set_displayContent">
<p>内容区域</p>
</div>
</div>
);
}
};
function APP (){
return (
<div className="head_top ">
<Head title="头部" />
</div>
)
};
ReactDOM.render(
<APP />,
document.getElementById('demo')
);
css
.conditionArea{
width: 100%;
height: 80px;
background-color:#66C6AD;
border: 1px solid blue;
text-align: center;
position: absolute;
}
.conditionArea_fixed{
position: fixed;
top: 0px;
z-index: 44;
}
url:https://www.cnblogs.com/jtjds/p/6936660.html
* */