Left property does not work in position Fixed

Asked

Viewed 231 times

2

I’m trying to make a div stay fixed at the bottom of the page, in the right corner, but not at the bottom of the page, so I used, as usual:

width:50px;
height:100px;
background:#fff;
position:absolute;
bottom:0;
left:10;

But div did not receive the property. I went to inspect element in the browser and under "left:10;" is an "Invalid Property value" notice. Can anyone tell me anything about this?

  • You have to indicate the unit px or pt etc..

  • Why it works with "bottom:0;" without the unit, and it doesn’t work with left and right?

  • May be a browser limitation.

2 answers

1

In the right corner, not leaning.

width:50px;
height:100px;
background:#fff;
position:absolute;
bottom:0;
right:10px;
  • In this case I will use position:Fixed, it has some difference?

  • The element will only stay fixed on the screen relative to the computer screen with position: fixed. With position: absolute element gets the position of the first parent element with position: relative or the element html.

0

It works as long as the parent element is with position: relative;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.