Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a div not move when scrolling?

Tags:

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

like image 958
user2629376 Avatar asked Jul 29 '13 07:07

user2629376


People also ask

How do you make a div not move when scrolling CSS?

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.

How do you make a div stick when scrolling?

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.

How do I stop div scrolling?

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.

How do I freeze a div?

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.


1 Answers

<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

like image 194
Natesan Avatar answered Oct 22 '22 10:10

Natesan