3Depth(level) ๋งŒ๋“ค๊ธฐ

2021. 10. 21. 16:52ยท๐ŸฃcodeLab
<div class="lnb">
	<ul>
        <li>
        	<a href="#">1Depth</a>
            <ul>
                <li>
                    <a href="#">- 2Depth</a>
                    <ul>
                        <li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                    </ul>
                </li>
                <li>
                	<a href="#">- 2Depth</a>
                    <ul>
                        <li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                    </ul>
                </li>
                <li><a href="#">- 2Depth</a></li>
                <li><a href="#">- 2Depth</a></li>
            </ul>
        </li>
        
        <li>
        	<a href="#">1Depth</a>
            <ul>
                <li>
                	<a href="#">- 2Depth</a>
                    <ul>
                        <li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                    </ul>
                </li>
                <li>
                	<a href="#">- 2Depth</a>
                    <ul>
						<li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                        <li><a href="#">- 3Depth</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        
        <li>
            <a href="#">1Depth</a>
            <ul>
                <li><a href="#">- 2Depth</a></li>
                <li><a href="#">- 2Depth</a></li>
            </ul>
        </li>
        
        <li><a href="#">1Depth</a></li>
    </ul>    
</div>
/* reset css */
* { margin: 0; padding: 0; }
li { list-style: none; }
a, a:active, a:focus { color :#222; text-decoration: none; }

/*************** 1Depth ***************/
.lnb { position: relative; width: 200px; }
.lnb > ul > li { border-bottom: 1px solid #dcdcdc; }
.lnb > ul > li > a { display: block; padding: 14px 35px; 14px 15px; font-size: 15px; background: seagreen url('https://cdn-icons-png.flaticon.com/512/1828/1828925.png') no-repeat center right 15px/10px auto; }
.lnb > ul > li:hover > a { color: #fff; background-color: seagreen; }
.lnb > ul > li.on > a { color: #fff; background: seagreen url('https://cdn-icons-png.flaticon.com/512/860/860821.png') no-repeat center right 15px/10px auto; }

/*************** 2Depth ***************/
.lnb > ul > li ul { display: none; }
.lnb > ul > li ul > li > a { display: block; padding: 14px 25px 14px 14px; font-size: 13px; background: #f5f2ec url('https://cdn-icons-png.flaticon.com/512/1828/1828925.png') no-repeat center right 15px/10px auto; }
.lnb > ul > li ul > li:hover > a { color: seagreen; background-color: #f5f2ec; }
.lnb > ul > li ul > li.on > a { color: seagreen; background: #f5f2ec url('https://cdn-icons-png.flaticon.com/512/860/860821.png') no-repeat center right 15px/10px auto; }

/*************** 3Depth ***************/
.lnb > ul > li ul li ul { display: none; }
.lnb > ul > li ul li ul li a { display: block; padding: 10px 25px; font-size: 12px; background-color: #fff; }
.lnb > ul > li ul li ul li:hover a { text-decoration: underline; }


.lnb ul li.noDepth a { background-image: none; }
// jQuery
var lnbUI = {
    clickE: function(target) {
        var $target = $(target);
        
        // ์•„๋ž˜ Depth๊ฐ€ ์—†์œผ๋ฉด background-image: none;
        $(target).each(function() {
           if($(this).find('> ul').length > 0) {
               return true;
           }
            $(this).addClass('noDepth');
        });
        
        $target.on('click', 'a', function() {
            var $this = $(this);
            var $depthTarget = $this.next(); // ul
            var $siblings = $this.parent().siblings(); // li
            
            if($this.parent('li').hasClass('noDepth') === false) {
				// removeClass('on'); ํ•ด์ค€๋‹ค.
                $('.lnb ul li ul li').removeClass('on');
                // == $this.parent('li').find('ul li').removeClass('on');
                
                $this.parent().siblings().removeClass('on');
                
                // 2,3Depth๊ฐ€ slideUp
                $this.parent('li').siblings('li').find('ul').slideUp();
                $this.parent('li').find('ul ul').slideUp();
                
                if($depthTarget.css('display') === 'none') {
                    $depthTarget.slideDown();
                    $this.parent('li').addClass('on');
                } else {
                    $depthTarget.slideUp();
                    $this.parent('li').removeClass('on');
                }
            } else {
                return false;
                // console.log('noDepth :: ul์—†์œผ๋ฉด ๋งํฌ์ด๋™');
            }
            return false;
        });
    }
}
lnbUI.clickE('.lnb li')

 

Reference

https://webclub.tistory.com/368

์ €์ž‘์žํ‘œ์‹œ ๋น„์˜๋ฆฌ ๋™์ผ์กฐ๊ฑด (์ƒˆ์ฐฝ์—ด๋ฆผ)
'๐ŸฃcodeLab' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • column-count์‚ฌ์šฉํ•˜์—ฌ masonry ๋‚˜ํƒ€๋‚ด๊ธฐ
  • ๋ชจ๋ฐ”์ผ ๋ธŒ๋ผ์šฐ์ €์—์„œ 100vh ์˜ค๋ฅ˜(์ง์ ‘ํ•ด๋ณด๊ธฐ)
  • <select> ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ๋งŒ๋“ค์–ด๋ณด๊ธฐ
  • ์ด๋ฏธ์ง€ ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋งŒ๋“ค๊ธฐ(image card list) +์ถ”๊ฐ€์ˆ˜์ •
jmjm
jmjm
  • jmjm
    /* jmjmjm */
    jmjm
  • ์ „์ฒด
    ์˜ค๋Š˜
    ์–ด์ œ
    • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (125)
      • ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ปSTUDY (87)
        • HTML (9)
        • CSS (25)
        • SASS (4)
        • JavaScript (16)
        • jQuery (9)
        • Publishing (8)
        • Git (11)
        • React (3)
        • Vue (0)
        • ์›น์ ‘๊ทผ์„ฑ (1)
        • Gulp (1)
      • ๐ŸฃcodeLab (27)
      • ๐ŸŒˆetc (8)
      • ๐Ÿฅฐ ์ผ์ƒ (2)
      • ๐ŸŒŸ์ฝ์–ด๋ณด๊ธฐ (1)
  • ๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

    • ํ™ˆ
    • ํƒœ๊ทธ
  • ๋งํฌ

  • ๊ณต์ง€์‚ฌํ•ญ

  • ์ธ๊ธฐ ๊ธ€

  • ํƒœ๊ทธ

    vscode ๋‹จ์ถ•ํ‚ค
    html collection
    ํ˜•์ œ์ธ์ ‘์ž display none
    javascript htmlcollection nodelist
    ํ˜•์ œ์ธ์ ‘์ž
    javascript slidedown
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ slidedown
    sass
    javascript htmlcollection
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ‘œํ˜„์‹๋ฌธ
    css ๊ฐ€์ƒ์„ ํƒ์ž
    sticky codepen
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ‘œํ˜„์‹ ๋ฌธ
    HTML Form
    javascript ์ปฌ๋ ‰์…˜
    javascript slideup
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ปฌ๋ ‰์…˜
    sticky jsfiddle
    ์ ‘๊ทผ์„ฑ ์ฃผ์˜์‚ฌํ•ญ
    sass compiler
    ์›น์ ‘๊ทผ์„ฑ
    ์•„์ฝ”๋””์–ธ๋ฉ”๋‰ด
    javascript nodelist
    react import export
    sticky ํ™œ์šฉ
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ slideup
    CSS ์„ ํƒ์ž
    css flex
    css ํ˜•์ œ์ธ์ ‘์ž ์•ˆ๋ผ์š”
    ํ˜•์ œ์ธ์ ‘์ž ์•ˆ๋˜๋Š” ์ด์œ 
  • ์ตœ๊ทผ ๋Œ“๊ธ€

  • ์ตœ๊ทผ ๊ธ€

  • hELLOยท Designed By์ •์ƒ์šฐ.v4.10.3
jmjm
3Depth(level) ๋งŒ๋“ค๊ธฐ
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”