css 메뉴 분할
조회수 1769회
안녕하세요.
기초적인 CSS 같은데 제가 문외한이라 도움을 요청드립니다.
아래 메뉴바 보시면 메뉴 1과 메뉴2가 일정한 크기로 왼쪽으로 쏠려 있는데요
메뉴1과 메뉴2를 50% 나누어 보이게 하려면 어디를 수정해야 하는지요.. 전체크기(100%)에서 50%는 메뉴1 나머지 50%는 메뉴 2로 하고 싶습니다.
도움 부탁드립니다.
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
border-right:1px solid #bbb;
}
li:last-child {
border-right: none;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #4CAF50;
}
</style>
</head>
<body>
<ul>
<li><a class="active" href="#home">메뉴1</a></li>
<li><a href="#news">메뉴2</a></li>
</ul>
</body>
</html>
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
ul의 width를 100%로 가득채우고 display를 table로 하고,
li에서 float:left를 대신에 display: table-cell를 지정하시면,
각 li들이 table 형식에 맞게 보여집니다.
ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; width: 100%; display: table; } li { border-right:1px solid #bbb; display: table-cell; }
-
(•́ ✖ •̀)
알 수 없는 사용자
-
댓글 입력