Questions tagged [getcomputedstyle]

80 questions
1
vote
1 answer

js how can I get the source css rule in getComputedStyle rule

as we know that with window.getComputedStyle() method we can get the computed styles of specific element. (see https://jsfiddle.net/r7sgpyt5/1/). My question is,how can we know where the CSSStyleDeclaration in the computed style come from.for…
Tsingbo
  • 11
  • 1
1
vote
0 answers

JavaScript mouseover/mousemove cusor postion without clicking in input text box

I'm attempting to combine a JavaScript mechanism for auto placing the users cursor inside of an input box through the mouseover and mousemove listeners. I have an almost perfect working example here: http://codepen.io/anon/pen/doxNLm?editors=101 …
Null
  • 123
  • 7
1
vote
1 answer

Are any events fired on Computed Style Change?

Is there an event I can listen for in JavaScript that tells me the computed style for a particular DOM element has changed? If not, what is the least blocking way to get the computed style of a DOM element using JavaScript?
user1739757
1
vote
2 answers

Retrieve Custom CSS Property Value with JavaScript - Must not be possible

The goal is to define a custom CSS property value in an external style sheet. Fiddle It External CSS: #myDiv { --myCustomProperty: 'myCustomValue'; } Markup:
There is nothing in the CSS spec that says…
1
vote
1 answer

Firefox won't display hidden div when shown using jQuery

I'm building a website that has a floating vimeo iframe in the center. By default, the vimeo container is set to "display:none;". Once the play button is clicked, I use jQuery to fade the iframe in. It works in all browsers except for Firefox. I'm…
Eric Wood
  • 529
  • 1
  • 9
  • 20
1
vote
1 answer

accessing pseudo-element property values through getComputedStyle in dart

I wish to detect what media query is active - I'm using Bootjack, so hence I am using the default breakpoints I expected to be able to use getComputedStyle() to get hold of the value of the 'content' property in the example below - but I don't seem…
0
votes
1 answer

Use getComputedStyle to identify the CSS font-weight for all P tags

Objective To use getComputedStyle to identify the CSS font-weight assigned to text in a page and note this as text into a span at the start of the P tag/s. Reason To create a bookmarklet for personal use in identifying where CSS is used to apply…
Laurence L
  • 585
  • 6
  • 17
0
votes
1 answer

How to retrieve current style value with JS as a number and not a word?

I use getComputedStyle(element)[type], where element is my

tag and type is either fontSize, lineHeight, letterSpacing, fontFamily or width. For fontSize and width, I get numerical values, like 16px and 100%. Which is something I can work with,…

Mähnenwolf
  • 138
  • 1
  • 13
0
votes
1 answer

What does `getComputedStyle` return and how to iterate over it?

Looking to get all the styles of a specific element via JavaScript. getComputedStyle works fine, however I'm confused what type of object it returns and how to best iterate over it. While some other answers have suggested iterating it over an array…
Afs35mm
  • 447
  • 6
  • 18
0
votes
1 answer

getComputedStyle(element).getPropertyValue("--varName") does not work in firefox

Well, I want to use some css vars in my js code. Here is the part of my .css file and the .js code: const root = document.querySelector(":root"); const msgColor =…
0
votes
0 answers

How to set the return type of window.getComputedStyle for different elements?

The return type of getComputedStyle is CSSStyleDeclaration. The type CSSStyleDeclaration in lib.dom.d.ts does not contain r, but the return object below does have an r property as you can see in the console log. How can I instruct TypeScript to use…
user1283776
  • 12,822
  • 32
  • 103
  • 190
0
votes
1 answer

GetAttribute in Selenium VBA for style

I am working on selenium in VBA and I have stored a variable"post" to store all the occurrences of a specific element like that Dim post As Object Set post = .FindElementsByCss("#DetailSection1") Dim i As Long For i = 1 To post.Count …
YasserKhalil
  • 5,029
  • 2
  • 13
  • 39
0
votes
0 answers

How to determine whether an element is displayed inline or as a block in JavaScript?

The problem: Given a HTML element and potentially some children, can you (and how can you) determine whether it is or will display it's children in a left/right flow (inline) or top-bottom flow (block)? This problem comes up, e.g., when you want to…
beorn
  • 11
  • 2
0
votes
1 answer

Removing inline CSS affects styles defined in stylesheet

I'm facing a strange behavior. I have a script that applies inline CSS to elements from its stylesheet with computedStyle method. This is a way to copy rich text instead of plain text. But after the copy, I need to delete the style=""…
Loarg Ann
  • 149
  • 11
0
votes
1 answer

JavaScript Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

I'm trying to make a little square disappear when clicked but only if it's the wrong choice. The problem is that I want it to fade away slowly and I have some issue selecting the square. for (var i = 0; i < difficulty; i++) { …
Pepe
  • 35
  • 6