LEETY
@enyalife12235952
Reviews Written
3
Average Rating
5.0
Posts
Q&A
3๊ฐ์ ๋ฌธ์์ ์ง๋ฌธ๋๋ ค์
๊ฐ์ฌํฉ๋๋ค:) ๋ ๋ฐฐ์ฐ๊ณ ๊ฐ๋ค์~ ์ถ์ ์ ๋ณด๋ด์ธ์!
- 0
- 5
- 296
Q&A
3๊ฐ์ ๋ฌธ์์ ์ง๋ฌธ๋๋ ค์
DOCTYPE html> html lang="en"> head> meta charset="UTF-8"> meta name="viewport" content="width=!, initial-scale=1.0"> title>Documenttitle> style> *{margin:0;padding:0;box-sizing: border-box;} ul{list-style-type:none;} #wrap { width:100vw; height:100vh; background-color:#eee; display:flex; align-items:center; justify-content:center; } .content{ width:30vw; height:30vw; border:1px solid #000; } .menu { display:flex; } .menu li{ width:25%; text-align:center; border-right:1px solid #fff; height:25px; } .menu li a{ display:block; color:#fff; background-color:rgb(109, 198, 240); height:25px; text-decoration:none; } .menu li.On a{ background-color:#000; } .menu li:last-child{ border-right:none; } .box { width:100%; height:calc(100% - 25px); position:relative; } .box .inner{ position:absolute; width:100%; height:100%; font-size:5vw; justify-content:center; display:flex; align-items:center; opacity:0; } .box .inner.Active{ opacity:1 } .box .inner.b01{ background-color:rgb(113, 156, 236); } .box .inner.b02{ background-color:rgb(236, 113, 195); } .box .inner.b03{ background-color:rgb(236, 199, 113); } .box .inner.b04{ background-color:rgb(236, 172, 113); } style> head> body> div id="wrap"> div class="content"> ul class="menu"> li >a href="#" class="btn"> 0menua>li> li>a href="#" class="btn"> 1menua>li> li>a href="#" class="btn"> 2menua>li> li>a href="#" class="btn"> 3menua>li> ul> ul class="box"> li class="inner b01 Active" data-index="0">content01li> li class="inner b02" data-index="1">content02li> li class="inner b03" data-index="2">content03li> li class="inner b04" data-index="3">content04li> ul> div> div> script> (function(){ const menuList = document.querySelector('.menu'); let currentItem; const content=document.querySelector('.box'); const inner = content.childNodes; console.log(inner); function handler(e){ const targetElem = e.target; // console.log(targetElem); if(currentItem){ currentItem.classList.remove('On'); } if(targetElem.classList.contains('btn')){ targetElem.parentNode.classList.add('On'); currentItem= targetElem.parentNode; } } menuList.addEventListener('click',handler); // data-index ์ถ๊ฐ menuList.querySelectorAll(".btn").forEach(function (item, i) { item.dataset.index = i; console.log(i) if(content.childNodes.classList.contains('inner')){ content.childNodes.dataset.index[i].classList.add('Active') } }); })() script> body> html> ์ด๋ ๊ฒ ์ฐ๋ ์๋ฌ๊ฐ ๋จ๋ค์~ ใ ใ ์์์์์ dataset์ค index๊ฐ i ์ธ ์์ดํํ ํด๋์ค ๋ถ์ฌ๋ผ๋ผ๊ณ ์๊ฐํ๊ฑด๋ฐ ์๋ชป๋ ์ ์ด ๋ฌด์์ผ๊น์
- 0
- 5
- 296
Q&A
top/left ์ bottom/right ์ชฝ mousemove๊ฐ ์ ์๋๋๊ฑฐ ๊ฐ์์์. code์ ๋ฌธ์ ๊ฐ ์๋์ง ํ๋ฒ ๋ด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
์ผ ๋ค ์คํ ๋๋ฌธ์ด๋ค์ ๊ฐ์ฌํด์!
- 0
- 2
- 259
Q&A
1๋ถ์ด๊ฐ ๊ณ์ ํ์๋ฆฌ์๋ง ์๊ธฐ๋๋ฐ์. info.xPos๊ฐ ์ผ๋ถ์ด์๊ฒ ์๋ค์ด๊ฐ๋๊ฑฐ ๊ฐ์์. ๋์น๋ถ๋ถ์ด ์๋๊ฑฐ๊ฒ ์ฃ ?
๊ฐ์ฌํฉ๋๋ค!
- 0
- 2
- 205




