This is my code on github私はスティッキー
これは、私はこれは私がjavascriptの
を使用しています私のhtmlコードであることべたつきvar h = document.getElementById("sticky_menu");
var stuck = false;
var stickPoint = getDistance();
function getDistance() {
var topDist = h.offsetTop;
return topDist;
}
window.onscroll = function(e) {
var distance = getDistance() - window.pageYOffset;
var offset = window.pageYOffset;
if ((distance <= 0) && !stuck) {
h.style.position = 'fixed';
h.style.top = '0px';
h.style.paddings ='1px';
h.style.margins='1px';
stuck = true;
} else if (stuck && (offset <= stickPoint)){
h.style.position = 'static';
stuck = false;
}
}
This is what I get after scrolling
作るために使用するものであることを表の一番上の行についてのヘルプが必要です
<tr id="sticky_menu" class="comparison" >
<th width="24%" class="tl tl2"></th>
<th width="19%" class="product" style="background:#f96e5b; border-top-left-radius: 5px; border-left:0px;">Exchange Online Plan 1</th>
<th width="19%" class="product" style="background:#f96e5b;">Office 365 Business Essential </th>
<th width="19%" class="product" style="background:#f96e5b;">Office 365 Business </th>
<th width="19%" class="product" style="border-top-right-radius: 5px; border-right:0px; background:#f96e5b;">Office 365 Business Premium</th>
</tr>
<tr >
? – gcampbell
位置を使用する場所:スティッキー? –
ポリフィルを使いたい場合を除き、それは実際にはあまり良い考えではありません。 – gcampbell