使div从底部开始

这是我的网站的测试图像。当前,当您向下滚动屏幕时,顶部的块会变大,但它来自顶部。我如何才能从底部开始?与偏移量有关吗? div被称为stem,底部的div被称为timeline

使div从底部开始

function showStem() {
  var stemb = $(".stem-background");
  var stem = $(".stem");
  var timeline = $(".timeline");
  var timelineot = timeline.offset().top;
  var h = document.documentElement.clientHeight;
  
  $(window).scroll(function() {
    var scroll = $(window).scrollTop();
    if (scroll > timelineot - h) {
      stemb.hide();
      stem.show();
      stem.height(scroll + h - timelineot);
    } else {
      stemb.hide();
      stem.hide();
    }
  });
}
.timeline {
    background: #112C30;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    font-size: 15px;
    line-height: 26px;
    color: #B9CFD0;
    overflow: hidden;
}

.timeline a {
    color: #B9CFD0;
    text-decoration: none;
    border-bottom: 1px solid #B9CFD0;
}

.timeline h1,h2,h3,h4,h5,h6 {
    font-family: 'Comfortaa',cursive;
}

.main-content {
    margin: 0 auto;
    position: relative;
}

.main-content .section-inner,.main-content .post-wrapper {
    *zoom: 1;
}

.main-content .section-inner:before,.main-content .section-inner:after,.main-content .post-wrapper:before,.main-content .post-wrapper:after {
    content: "";
    display: table;
}

.main-content .section-inner:after,.main-content .post-wrapper:after {
    clear: both;
}

.section .section-inner {
    margin: 0 auto;
    width: 1024px;
}

@media only screen {
    .section .section-inner {
        width: auto;
        max-width: 1024px;
    }
}


.stem-wrapper {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    z-index: auto;

}


.stem-wrapper.color-yellow .stem-background {
    background: #E9E566;
}

.stem-wrapper.color-green .stem-background {
    background: #35C189;
}

.stem-wrapper.color-white .stem-background {
    background: #FFF;
}

.stem-wrapper .stem,.stem-wrapper .stem-background {
    position: absolute;
    top: 0;
    left: -30px;
    width: 60px;
}

.stem-wrapper .stem{
    background: #1e4f56;
    overflow: hidden;
    height: 100%;
}

.stem-wrapper .stem-background {
    background: #ecf6f9;
    height: 50%;

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="timeline">
  <div class="stem-wrapper">
    <div class="stem"></div>
    <div class="stem-background"></div>
  </div>
  <!-- more content -->
</div>

我已经在CSS中尝试了一些方法,但是很多溢出都是多余的。

yan_xiao_yu11 回答:使div从底部开始

我得到了我要找的答案

stem.offset({top:timelineot});

timelineot+50timelineot-50进行了测试

本文链接:https://www.f2er.com/3159002.html

大家都在问