Click here to Skip to main content
15,888,100 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to fix top header logo to stay fixed while scroll down.

Kindly suggest.
Please look at this code

What I have tried:

<pre><div class="header-logo-container">
<a href="#" class="custom-logo-link" rel="home"><picture class="custom-logo">
<source type="image/webp" srcset="#" />
<img width="250" height="99" src="#" alt="#" />
</picture>
</a> </div>
Posted
Updated 27-Apr-20 1:32am
v2

1 solution

Use "sticky" positioning:
position - CSS: Cascading Style Sheets | MDN[^]
CSS
.header-logo-container {
    position: sticky;
    top: 0;
}
Browser support is pretty good - almost everything except Internet Explorer supports it:
Can I use... Support tables for HTML5, CSS3, etc[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900