배경 이미지가 크롬에서 cssImageValue가 아닌 이유는 무엇입니까? 캔버스를 배경 이미지로 처리하지만 새 이미지를 만들지 않으려면 어떻게해야합니까?

오카 방어

이 기사 기반 : https://developer.mozilla.org/en-US/docs/Web/API/CSSImageValue

const allComputedStyles = button.computedStyleMap(); 
// Return the CSSImageValue Example 
console.log( allComputedStyles.get('background-image') );

하지만 크롬에서는 :

var img=imgelement.computedStyleMap().get('background-image')
canvas.getContext('2d').drawImage(img,0,0,img.width,img.height);
//output: Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'
//: The provided value is not of type '(CSSImageValue ....

캔버스를 사용하여 배경 그림이 검은 색인지 확인하고 싶지만 크롬에서는 어떻게 할 수 있습니까?

btw, 배경 이미지의 URL로 새 이미지 태그를 만들고 싶지 않았습니다. 좀 더 직접적인 방법을 알려주세요.

오카 방어

마지막 업데이트, 마지막으로 배경 이미지에 둘 이상의 값이 있기 때문에 진실을 찾았습니다.

//here is cssstylevalue
background-image: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.65)), url("http://localhost:8080/icons/we-flow.png");

//here is cssimagevalue
background-image: url("http://localhost:8080/icons/we-flow.png"); 

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관