Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 sticky-top margin-top

I have element sidebar and div with class sticky-top:

<div class="row">
   <div class="col-lg-4">
      <div class="sticky-top">
           ....
      </div>
   </div>
</div>

I need pass a margin, when sidebar is sticky, because class sticky-top doesn't have a margin-top.

How I can write margin when sidebar is sticky?

like image 859
Dumitru Avatar asked Jun 24 '18 06:06

Dumitru


2 Answers

Try:

.sticky-top { top: 0.5em; }
like image 162
לבני מלכה Avatar answered Oct 31 '22 04:10

לבני מלכה


You need to use top instead of margin-top

<div class="row">
    <div class="col-lg-4">
        <div class="sticky-top" style="top: 30px">
            ....
        </div>
    </div>
</div>
like image 45
Pasq Avatar answered Oct 31 '22 03:10

Pasq