要素に適用されているスタイルを調べる
スタイルの値を取得する。
getComputedStyle(要素).プロパティ名
<style>
.sample {
font-size: 30px;
background-color: rgba(0, 0, 255, .2);
}
</style>
<script>
console.log(getComputedStyle(document.querySelector(".sample")).fontSize); // 30px
console.log(getComputedStyle(document.querySelector(".sample")).backgroundColor); // rgba(0, 0, 255, 0.2)
console.log(getComputedStyle(document.querySelector(".sample")).fontFamily); // "Noto Serif"
</script>