메뉴 정렬??
본문
아래는 css 파일이고
현재의 메뉴 배열을 가운데로 하고싶은데 방법을 모르겠습니다.
고수님들 조언부탁드립니다.
/* PC 상단메뉴 */
#hd_menu{clear:both; width:100%;position:relative; text-align:left; background:#444; height:52px; border-top:1px solid #444; border-bottom:1px solid #444;}
#hd_menu .hd_menu_all{position:relative; width:100%; max-width:1400px; margin:0 auto;}
#hd_menu button#menu_open{color:#000; width:50px; height:50px; line-height:50px; background:#fff; border:0px; padding:0; text-align:center;}
#hd_menu button#menu_open i{font-size:1.3em;}
#hd_menu .ul_1st{width:100%;}
#hd_menu .ul_1st > li{float:left; margin:0; padding:0; position:relative;}
#hd_menu .ul_1st > li > a{display:block; width:100%; padding:0 16px; font-size:1em; font-weight:400; color:#fff; height:50px; line-height:50px;}
@media screen and (-webkit-min-device-pixel-ratio:0){
#hd_menu .ul_1st > li > a{padding:0 16px; font-size:1.1em;} /* ie11을 제외한 모든 부라우저*/
}
#hd_menu .ul_1st > li > a > i{margin-left:5px;}
#hd_menu .ul_1st > li:hover > a{color:#ccc;}
#hd_menu .ul_1st > li:last-child > a{padding-right:0px;}
#hd_menu .ul_2nd{display:none; position:absolute; top:51px; left:0; width:150px; text-align:left; margin:0; padding:0; z-index:999;}
#hd_menu .ul_2nd > li{padding:0px; width:100%; margin:0; background:rgba(68, 68, 68, 1);}
#hd_menu .ul_2nd > li > a{display:block; width:100%; height:35px; line-height:32px; font-size:0.95em; color:#fff; text-decoration:none; text-align:left; text-indent:14px; }
#hd_menu .ul_2nd > li > a:hover{background-color:#029DB1; color:#fff;}
#hd_menu .ul_2nd > li > a > i{display:none;}
#hd_menu .ul_2nd > li.active > a{background-color:#029DB1; color:#fff;}
#hd_menu .ul_3rd{position:absolute; display:none; ; left:150px; width:150px; background:#fff; padding:0; margin:0; z-index:9999; margin-left:0px; margin-top:-35px; box-sizing:border-box;}
#hd_menu .ul_3rd > li{padding:0px; width:100%; height:35px; margin:0; background:rgba(68, 68, 68, 1); border-left:1px solid #000;}
#hd_menu .ul_3rd > li > a{display:block; width:100%; height:35px; line-height:32px; font-size:1em; color:#fff; text-decoration:none; text-align:left; text-indent:14px; }
#hd_menu .ul_3rd > li > a:hover{background-color:#029DB1; color:#fff;}
#hd_menu .ul_3rd > li > a > i{display:none;}
#hd_menu .ul_3rd > li.active > a{background-color:#029DB1; color:#fff;}
#hd_menu .ul_4th{position:absolute; display:none; left:148px; width:150px; background:#fff; padding:0; margin:0; z-index:9999; margin-left:0px; margin-top:-35px; border:0px solid #ccc; box-sizing:border-box;}
#hd_menu .ul_4th > li{padding:0px; width:100%; height:35px; margin:0; background:rgba(68, 68, 68, 1); border-left:1px solid #000;}
#hd_menu .ul_4th > li > a{display:block; width:100%; height:35px; line-height:32px; font-size:1em; color:#fff; text-decoration:none; text-align:left; text-indent:14px; }
#hd_menu .ul_4th > li > a:hover, #hd_menu .ul_4th > li.active > a{background-color:#029DB1; color:#fff; }
#hd_menu .ul_4th > li > a > i{display:none;}
답변 2
.ul_1st > li 요소들이 float: left; 속성을 사용하고 있기 때문입니다.
*.ul_1st에 display: flex;, justify-content: center; 속성을 추가
*.ul_1st > li에서 float: left;를 제거하고 display: inline-block;으로 변경
#hd_menu .ul_1st {
display: flex;
justify-content: center; /* 가로 중앙 정렬 */
align-items: center; /* 세로 중앙 정렬 */
width: 100%;
padding: 0;
}
#hd_menu .ul_1st > li {
display: inline-block; /* 기존 float 제거 */
margin: 0;
padding: 0;
position: relative;
}
조언드립니다.
URL 을 올려주세요.