I have created this div on the top left of my website, which contains the logo. However, I want it to stay there and not move up and down when I am scrolling. Please advise.
<div style="padding: 5px 0 0 5px; height: 140px; width: 150px;"> <p align="left"> <img src="images/logo.png" border="5" alt="Logo" /> </p> </div>
Thanks
There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.
To make an element sticky, do: make_sticky('#sticky-elem-id'); When the element becomes sticky, the code manages the position of the remaining content to keep it from jumping into the gap left by the sticky element. It also returns the sticky element to its original non-sticky position when scrolling back above it.
To hide the scrollbar and disable scrolling, we can use the CSS overflow property. This property determines what to do with content that extends beyond the boundaries of its container. To prevent scrolling with this property, just apply the rule overflow: hidden to the body (for the entire page) or a container element.
2 Answers. Show activity on this post. Add position: relative; to container, and remove floats and add position: fixed; to the block you want to fixate. I have actually tried exactly that, except I had left:5px instead of left:5 , and then the div was positioned relatively to the page instead of its parent.
<div style="padding: 5px 0 0 5px; height: 140px; width: 150px;position:fixed;left:0;top:0">
for ref: http://www.w3schools.com/css/css_positioning.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With