,
pc 화면 뷰와 mobile 화면 뷰
표시 구성상 변경, 구별이 필요할때
<somsom-ad>
<template class="ad__mobile">
//mobile view
</template>
<template class="ad__desktop">
//desktop view
</template>
</somsom-ad>
mobile view, desktop view 작성
각 장치별 화면 확인
<script>
class AdComponent extends HTMLElement {
connectedCallback() {
const isMobile = matchMedia('(max-width: 500px)').matches;
const ad = document.currentScript.closest('.ad');
const content = this
.querySelector(isMobile ? '.ad__mobile' : '.ad__desktop')
.content;
this.appendChild(document.importNode(content, true));
}
}
customElements.define('somsom-ad', AdComponent);
</script>
[html]meta tag (0) | 2020.12.20 |
---|---|
[text]글자 수 제한 (0) | 2020.12.19 |
[Codeigniter]Model 모델 액세스 (0) | 2020.11.27 |
[Codeigniter]Array 헬퍼 (0) | 2020.11.26 |
[Codeigniter]Database Query (0) | 2020.11.25 |