테스트 사이트 - 개발 중인 베타 버전입니다

css만을 이용한 전체펼침메뉴 채택완료

우주열차 6년 전 조회 4,060

메뉴 a을 누르거나 b를 누를때마다 밑에 메뉴들이 전체로 나오게 하고싶은데 어디 부분을 건드려야 될지 모르겠습니다 jquery안쓰고 css만 이용해야되구 구조바꿔도 상관없습니다ㅜ 

일주일동안 고민중인데 가르켜주세영ㅠ

 

html소스는 

     
             
  • a            
                                                                                       
             
  •          
  • b            
                                                                                       
             
  •        
     

 

css 소스는

.header{   font-weight: bold;   width: 100%;   height: 20px;   box-sizing: border-box; }

body{   list-style: none; }

.header ul {     float: right;     height: 100%;     width: 40%;     font-size: 20px; } .header li ul .nav_detail a:hover {     background: black;     color: white; } body, h1, h2, h3, ul, ol, li {     padding: 0;     margin: 0; } .header li ul .nav_detail a {     width: 100%;     height: 100%;     position: absolute;     top: 0;     left: 0;     color: #fff;     text-align: center;     text-decoration: none; } .header li ul .nav_detail {     position: relative;     text-align: left;     font-size: 14px;     font-weight: bold;     color: #fff;     background: black;     line-height: 40px;     list-style: none;     width: 100%;     height: 40px;     cursor: pointer;     z-index: 9999; } ul {     display: block;     list-style-type: disc;     margin-block-start: 1em;     margin-block-end: 1em;     margin-inline-start: 0px;     margin-inline-end: 0px;     padding-inline-start: 40px; } .header>ul>li:hover {     color: gray; } .header li:hover {     background-color: inherit; } .header li {     position: relative;     text-align: center;     list-style: none;     float: left;     line-height: 20px;     width: 10%;     color: #444444;     cursor: pointer; } .header li:hover > ul {     display: block; } .header li ul {     display: none;     position: relative;     z-index: 9999;     width: 100%;     z-index: 9999; }

 

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
s
sinbi Expert
6년 전

li에 hover 줄 때 나타나게 하면 해당 li에 속한 애들만 나타나니,

ul에 hover 줄 때 나타나게 코드 수정해 보세요.

https://codepen.io/sinbi/pen/xvgOPX">https://codepen.io/sinbi/pen/xvgOPX 참고.

 

ps.

click 했을 때 나타나게 하는 건, js나 jquery 이벤트 기능 필수입니다.

css로는 hover 정도밖에 못 줍니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

6년 전

체크박스나 라디오박스를 이용하면 click했을때 순수css만으로 나타나게 할 수 있습니다

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

Rido
6년 전
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인