Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is element.style and why is it overriding my css settings?

Tags:

css

I have a popup that comes up over a blanket div that greys out the entire screen, but I don't like its positioning. So I tried to manually enter left: and top: elements into my CSS, but when I look at Chrome's console, there's this element.style {} that's overriding my code.

I've searched my CSS file for element.style and for 597px and 794px and I don't get hits on any of them.

What is this, and why does it have the values that it has?

enter image description here

like image 856
Brian Powell Avatar asked Feb 05 '15 20:02

Brian Powell


People also ask

Why is my CSS being overridden?

If you can see your new CSS in the Styles pane, but your new CSS is crossed out, it means that there's some other CSS that is overriding your new CSS. In CSS terminology this concept is called Specificity. Chrome DevTools can help you find the old CSS that is causing your new CSS to not be applied.

What is CSS style overriding?

CSS allows you to apply styles to web pages. More importantly, CSS enables you to do this independent of the HTML that makes up each web page. Overriding: Overriding in CSS means that you are providing any style property to an element for which you have already provided a style.

What is the element style?

element. style is a part of your browser devtools that indicates the inline style of the element which has a higher specificity value than any CSS selectors. That inline styles may be added by a JavaScript code, if so, you can override that declarations by using !

How do I get rid of element style?

You can remove CSS style properties from an element by setting the property to a null value, e.g. box. style. backgroundColor = null; . When an element's CSS property is set to null , the property is removed from the element.


2 Answers

element.style is a part of your browser devtools that indicates the inline style of the element which has a higher specificity value than any CSS selectors.

That inline styles may be added by a JavaScript code, if so, you can override that declarations by using !important keyword within your stylesheet (e.g. left: 610px !important).

like image 138
Hashem Qolami Avatar answered Nov 16 '22 04:11

Hashem Qolami


element.style refers to inline styles on the dom element. For example:

<p style="color:#cc0000;">Foo</p>

the color of that paragraph would show up under element.style.

You can fix with your css by doing this:

#popUpDiv[style]{
    left:610px !important;
    top:0px !important;
}

HTH -Ted

like image 21
Ted Avatar answered Nov 16 '22 02:11

Ted