๋ฐ˜์‘ํ˜•

์ธ์ž๋กœ ๋„˜๊ธด ์š”์†Œ์— ์ ์šฉ๋œ ๋ชจ๋“  CSS ์†์„ฑ ์กฐํšŒ


Window.getComputedStyle(element, [pseudoElt])

 

const styles = getComputedStyle(element);
// {0: 'accent-color', 1: 'align-content', 2: 'align-items', ...}
console.log(styles);

 

์ธ์ž๋กœ ๋„˜๊ธด CSS ์†์„ฑ์— ๋Œ€ํ•œ ๊ฐ’ ์กฐํšŒ


CSSStyleDeclaration.getPropertyValue(property)

 

const styles = getComputedStyle(element);
// 'normal' (align-items์— ๋Œ€ํ•œ ์†์„ฑ ๊ฐ’ normal ๋ฐ˜ํ™˜)
styles.getPropertyValue('align-items');
// 'normal' (์œ„์™€ ๋™์ผ)
styles.alignItems;

 


๊ธ€ ์ˆ˜์ •์‚ฌํ•ญ์€ ๋…ธ์…˜ ํŽ˜์ด์ง€์— ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค. ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด ์ฃผ์„ธ์š”
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€

๋Œ“๊ธ€์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.