File tree Expand file tree Collapse file tree 4 files changed +24
-5
lines changed
Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -117,4 +117,9 @@ export default {
117117footer {
118118 margin-top : 100px ;
119119}
120+
121+ #app ,
122+ main {
123+ position : relative ;
124+ }
120125 </style >
Original file line number Diff line number Diff line change @@ -107,11 +107,11 @@ export default {
107107 height : 60px ;
108108 align-items : center ;
109109 padding : 10px 100px ;
110- position : relative ;
110+ // position: relative;
111111 z-index : 1000 ;
112112 & .fixedToTop {
113113 position : fixed ;
114-
114+
115115 width : 100% ;
116116 }
117117 & .main-color {
Original file line number Diff line number Diff line change @@ -57,3 +57,12 @@ export function formatDate(date, format = true) {
5757
5858 return format ? `${ Y } -${ M } -${ d } ${ h } :${ m } :${ s } ` : `${ Y } -${ M } -${ d } ` ;
5959}
60+
61+ export function getOffsetTop ( relativeNode , node , topSum = 0 ) {
62+ topSum += node . offsetTop ;
63+
64+ if ( node . offsetParent !== relativeNode ) {
65+ return getOffsetTop ( relativeNode , node . offsetParent , topSum ) ;
66+ }
67+ return topSum ;
68+ }
Original file line number Diff line number Diff line change 44
55 <!-- 搜索 -->
66 <div ref =" searchBar" :class =" { fixedTop: searchBarFixedTop }" class =" search-wrapper" >
7- <input-search placeholder =" 搜索职位" v-model =" searchKeyword" ></input-search >
7+ <input-search
8+ :size =" searchBarFixedTop?'small':'medium'"
9+ placeholder =" 搜索职位"
10+ v-model =" searchKeyword"
11+ ></input-search >
812 </div >
913
1014 <div class =" main clearfix" >
6165 </div >
6266</template >
6367<script >
68+ import { getOffsetTop } from " @/helper/utilities" ;
6469let positionY = 0 ;
6570let searchBarClientHeight = 0 ;
6671
@@ -106,13 +111,13 @@ export default {
106111 },
107112 mounted () {
108113 this .$nextTick (() => {
109- positionY = this .$refs .searchBar . offsetTop ;
114+ positionY = getOffsetTop ( document . body , this .$refs .searchBar ) ;
110115 searchBarClientHeight = this .$refs .searchBar .clientHeight ;
116+
111117 });
112118 },
113119 activated () {
114120 const onPageScroll = () => {
115-
116121 const top = this .$refs .searchBar .getBoundingClientRect ().top ;
117122
118123 this .searchBarFixedTop =
You can’t perform that action at this time.
0 commit comments