Просто добавьте класс h-100
к липкой вершине и ее внутреннему div.
body, html {
height: 100%;
}
#element-1 {
background: lightgray;
overflow: auto;
}
#element-2 {
background: gray;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid h-100">
<div class="row">
<div class="col-8" id="element-1">
Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content
</div>
<div class="col-4" id="element-2">
<div class="sticky-top h-100">
<div class="d-flex h-100 justify-content-center flex-column">
<div class="text-center">I should be center vertically</div>
</div>
</div>
</div>
</div>
</div>
Вы также можете удалить внутренний div с липким верхом, если он вам не нужен:
body, html {
height: 100%;
}
#element-1 {
background: lightgray;
overflow: auto;
}
#element-2 {
background: gray;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid h-100">
<div class="row">
<div class="col-8" id="element-1">
Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content
</div>
<div class="col-4" id="element-2">
<div class="sticky-top d-flex h-100 justify-content-center flex-column">
<div class="text-center">I should be center vertically</div>
</div>
</div>
</div>
</div>
РЕДАКТ. 1 Извините, я не заметил проблемы с залипанием
Я использовал добавление второго решения:
.sticky-top{
height:100vh;
}
body, html {
height: 100%;
}
#element-1 {
background: lightgray;
height: 1000px;
overflow: auto;
}
#element-2 {
background: gray;
}
.sticky-top{
height:100vh;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid h-100">
<div class="row">
<div class="col-8" id="element-1">
Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content Some Content
</div>
<div class="col-4" id="element-2">
<div class="sticky-top d-flex justify-content-center flex-column">
<div class="text-center">I should be center vertically</div>
<div class="text-center">I should be center vertically</div>
</div>
</div>
</div>
</div>