getcomputedstyle

if statement in JavaScript game not working as desired to allow for collision detection

蹲街弑〆低调 提交于 2021-02-10 14:14:50
问题 I'm working through some basic steps in an HTML, CSS and JScript game to get very simple collision detection working between a CHARACTER and an ENEMY. I am looking for something that is simple enough to explain to children of age 8 - 11. If the character and the enemy collide then "game over". I have tried various things, but require some help with the code and an explanation of getComputedStyle method and what Properties it gets, for me to effectively create the main if statement. This is

getPropertyValue(“backgroundColor”) returns an empty string

瘦欲@ 提交于 2021-01-28 10:21:02
问题 This is my problem: var mycss = window.getComputedStyle(myelement); returns a CSSStyleDeclaration object: CSSStyleDeclaration {0: "animation-delay",..., backgroundColor: "rgb(0, 0, 0)",...} Then, I want to get the background color, but mycss.getPropertyValue("backgroundColor"); returns an empty string "" ! Why?? 回答1: Within your CSSStyleDeclaration, you need to change 'backgroundColor' to 'background-color' and then call mycss.getPropertyValue('background-color') An example: HTML: <head>

getPropertyValue(“backgroundColor”) returns an empty string

青春壹個敷衍的年華 提交于 2021-01-28 10:20:45
问题 This is my problem: var mycss = window.getComputedStyle(myelement); returns a CSSStyleDeclaration object: CSSStyleDeclaration {0: "animation-delay",..., backgroundColor: "rgb(0, 0, 0)",...} Then, I want to get the background color, but mycss.getPropertyValue("backgroundColor"); returns an empty string "" ! Why?? 回答1: Within your CSSStyleDeclaration, you need to change 'backgroundColor' to 'background-color' and then call mycss.getPropertyValue('background-color') An example: HTML: <head>

How to get child property value of a element property using selenium webdriver, NUnit and C#

社会主义新天地 提交于 2020-04-16 04:59:23
问题 I am testing websites using selenium webdriver and I am having difficulties getting the value of a property that is a child of another property. For me, this 2nd/child level is always coming back as null. When trying to get a value of an upper level attribute/property it is working fine with the following code: return Element1.GetAttribute("baseURI"); return Element2.GetAttribute("innerText"); Those above return the text/string that I am expecting. However if I try and get the value of a

How to get child property value of a element property using selenium webdriver, NUnit and C#

蹲街弑〆低调 提交于 2020-04-16 04:58:39
问题 I am testing websites using selenium webdriver and I am having difficulties getting the value of a property that is a child of another property. For me, this 2nd/child level is always coming back as null. When trying to get a value of an upper level attribute/property it is working fine with the following code: return Element1.GetAttribute("baseURI"); return Element2.GetAttribute("innerText"); Those above return the text/string that I am expecting. However if I try and get the value of a

How to get actual CSS property value of an HTML element node? [duplicate]

狂风中的少年 提交于 2019-12-23 12:30:17
问题 This question already has answers here : How to get computed background color style inherited from parent element (2 answers) Closed last year . As I understand the getComputedStyles() method, it should return an object that allows one to access the actual CSS property values of an HTML element node. I created this simple example with a paragraph containing a span: let span = document.getElementsByTagName("span")[0]; let style = window.getComputedStyle(span); span.innerText = "span background

why are initial CSS styles not visible on DOM element .style field?

风流意气都作罢 提交于 2019-12-22 18:14:54
问题 OK I have full expectation of going down in flames for asking something stupid (or at least duplicate), but in the attached snippet, why do I have to use window.getComputedStyle to access styles applied by CSS? I was under the impression that the .style field would at least reflect those styles initially applied by CSS, and/or manually changed since then. If not, what are the exact rules governing which properties are reflected (and when) in an element's .style field? setTimeout(() => {

window.getComputedStyle not working for shorthand properties in other browsers except Chrome

我们两清 提交于 2019-12-14 03:21:29
问题 window.getComputedStyle give the style's value in Chrome, but in firefox and Microsoft Edge it gives an empty string and in Internet Explorer, it say that it doesn't support that method. Here is my code. Whenever the Upvote image is clicked it fires the upDownVote() function, passing two arguments. This is the HTML. <div id="upvote" title="Click to UpVote" onClick="upDownVote('increment',<?php echo $id; ?>);"></div> <div id="downvote" title="Click to DownVote" onClick="upDownVote('decrement',

How to fix Window.getComputedStyle is not an object error

社会主义新天地 提交于 2019-12-06 18:22:09
问题 I am trying to use draggabilly available at https://github.com/desandro/draggabilly it works fine in html. Now when i have tried to add it in wordpress. I am getting following error in firebug console. TypeError: Argument 1 of Window.getComputedStyle is not an object. return s.getComputedStyle(t, null) here is a link for js file http://draggabilly.desandro.com/draggabilly.pkgd.min.js 回答1: You are calling init twice. Go through your code and remove one instance. 回答2: I received this error

getComputedStyle gives “transparent” instead of actual background color

寵の児 提交于 2019-12-06 01:15:33
问题 This was a surprise. The following code does not seem to give me the actual colors on the screen: h1 = document.querySelector("h1"); window.getComputedStyle(h1).color Gives rgb(0, 0, 0) which I think is correct. However window.getComputedStyle(h1).backgroundColor gives rgba(0, 0, 0, 0) . The actual background color I see on the screen is white. The element I call h1 is visible on the screen. I was expecting to get the actual background color. The value I get above (in rgba) is not wrong, but