javascript - Why is my !important style attribute getting overwritten in Chrome? -


this question has answer here:

i writing chrome extension. , need elements relative. added position: relative !important; body's style make of them relative. in page testing there js sets elements' values position: fixed. thought important attribute has priority in css, somehow element still fixed , not relative.

here getting in chrome inspect: enter image description here (notice position: fixed @ styles' top , position: relative !important @ bottom). , element still fixed.

if uncheck position: fixed rule inside chrome inspect, become relative, yeah, that's want do, want js make (actually, of elements) relative.

is there way accomplish this?

maybe question related this: why isn't !important attribute working in google chrome?, i'm not sure.

to apply style elements (which seems wrong / heavy-handed), you'd use javascript so:

var i; var bodyelems = document.getelementsbytagname( "body" ) ; var body = bodyelems[ 0 ] ; var tags = body.getelementsbytagname("*"); ( = 0; < tags.length; i++ ) {   tags[i].style.setproperty('position', 'relative', 'important'); } 

here fiddle


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -