Remove position:absolute attribute by adding css
Asked Answered
A

3

29

I have a html element with id="#item" I have a UI event that programaticaly alters the css for "#item" by adding the class ".new" to "#item". Initially I want "#item" to have "position:absolute". However once the class ".new" is added to "#item" the only way I can get the formatting I want in Chrome inspector is to removed position:absolute from the css for "#item". I'd like to accomplish this instead via the css in ".new", however in Chrome inspector my options for changing the position attribute are

static
absolute
relative
initial 
inherit
fixed

As far as I can tell none of these do the same thing as removing "position:absolute" in Chrome inspector. Can anyone suggest what to put in the css for ".new" to revert to the css default positioning.

Absurdity answered 13/10, 2013 at 22:41 Comment(3)
Try leaving the field blank and set important like this: position: !important;Headsman
position: static is default.Lindi
developer.mozilla.org/en-US/docs/Web/CSS/position described. Initial value is static.Relapse
L
54

http://jsbin.com/ICeweli/1/

#test {
  position: absolute;
}

#test {
  position: static;
}

Remove one or the other to see the difference.

Lindi answered 13/10, 2013 at 22:50 Comment(0)
A
21

The CSS2 specification says that the initial position value of an element is static.

So in your case if you can't actually remove a declaration then reset it to the "default" which is static.

#item {
    position: static;
}
Ageratum answered 13/10, 2013 at 22:50 Comment(0)
C
4

You cannot use 'none' as an option. For my need,

.search-bar{
    position: static;
}

did the job.

Campanile answered 30/6, 2020 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.