안뇽!


오늘부터 메뉴 관련해서 공부하느라 올린당 ㅎㅅㅎ


미래의 나야 과거의 나한테 고마워하면서 공부하자!


먼저 메뉴 만든당 

float이용해서 가로로 만들고 서브메뉴는 display: none으로 숨긴다!

여기서 <div class="none">을 넣었는데 그 이유는 메뉴가 슬라이드 되었을때

밑에 있는 컨텐츠 내용에 서브메뉴가 포함이 되어서 컨텐츠에 padding margin이 먹히지 않아 가상요소로 숨기려고 넣었다 ㅇㅁㅇ)9 혹시 나중에 더 쉬운방법이 있다면 그거로 하겠지만 지금은 모르니까 내가 아는 방법으로 넣었다



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<div class="logo">
            <span class="logo">컨텐츠 내용이 밀리는 풀 드롭다운 메뉴</span>
        </div>
        <div class="topMenu">
            <ul class="menu01">
                <li><span>Menu01</span>
                    <ul class="dept01">
                        <li id="nop">sub01</li>
                        <li id="nop">sub02</li>
                        <li id="nop">sub03</li>
                        <li id="nop">sub04</li>
                        <li id="nop">sub05</li>
                    </ul>
                </li>
                <li><span>Menu02</span>
                    <ul class="dept01">
                        <li id="nop">sub01</li>
                        <li id="nop">sub02</li>
                        <li id="nop">sub03</li>
                        <li id="nop">sub04</li>
                        <li id="nop">sub05</li>
                    </ul>
                </li>
                <li><span>Menu03</span>
                    <ul class="dept01">
                        <li id="nop">sub01</li>
                        <li id="nop">sub02</li>
                        <li id="nop">sub03</li>
                        <li id="nop">sub04</li>
                        <li id="nop">sub05</li>
                    </ul>
                </li>
                <li><span>Menu04</span>
                    <ul class="dept01">
                        <li id="nop">sub01</li>
                        <li id="nop">sub02</li>
                        <li id="nop">sub03</li>
                        <li id="nop">sub04</li>
                        <li id="nop">sub05</li>
                    </ul>
                </li>
                <li><span>Menu05</span>
                    <ul class="dept01">
                        <li id="nop">sub01</li>
                        <li id="nop">sub02</li>
                        <li id="nop">sub03</li>
                        <li id="nop">sub04</li>
                        <li id="nop">sub05</li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="none">
        </div>
cs

html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{margin: 0; padding: 0; }
li {list-style: none; }
body {font-family: 'Nanum Gothic', sans-serif; width: 1200px; margin: 0 auto; }
            
.logo {margin: 50px 0; font-size: 30px; text-align: center; font-family: 'Nanum Brush Script', cursive; }
            
.topMenu {width: 100%; margin-bottom: 20px; text-align: center; height: 40px; }
.topMenu:after {content: ""; display: block; clear: both; }
.menu01>li {float: left; width: 20%; line-height: 40px; }
.menu01 span {font-size: 20px; font-weight: bold; }
            
.dept01 {display: none; padding: 20px 0; border-bottom: 1px solid #ccc; }
            
#nop {float: none; }
            
.none:after {content: ""; display: block; clear: both; }
cs

css

1
2
3
4
5
6
7
8
$(document).on('mouseover''.topMenu span'function() {
    $('.dept01').slideDown(300);
});
$(document).on('mouseover''div'function () {
    if (!$(this).hasClass('topMenu')) {
        $('.dept01').slideUp(300);
    }
});
cs

JQuery


위에대로 해주면




일케 컨텐츠를 밀어내면서 나오는 풀 드롭다운 메뉴가 나온다!



'2018 > 공부한다!' 카테고리의 다른 글

[css] 스크롤바 색상변경  (0) 2018.07.27
[JQuery] 상단풀메뉴 드롭다운 (컨텐츠 안밀림)  (0) 2018.07.26