화면의 왼쪽에서 navbar를 만들고 navbar 바로 옆에서 텍스트 div를 만들어야합니다. 나는 텍스트 div를 화면의 오른쪽으로 줄이는 작업 만했습니다. 지금까지 나는이 있습니다두 div가 서로 옆에 있도록하려면 어떻게해야합니까?
HTML
<head>
<link rel = "stylesheet" type = "text/css" href = "styles.css">
<title>Homepage</title>
</head>
<body>
<div id = "header">
<h1>Homepage - origins of World Wide Web and the Internet</h1>
</div>
<div id = "wrapper">
<div id = "navbar">
<ul>
<li><a class = "active" href="index.html">HOMEPAGE</a></li>
<li><a href="news.asp">INTERNET PIONEERS</a></li>
<li><a href="contact.asp">HTTP</a></li>
<li><a href="about.asp">TERMINOLOGY</a></li>
<li><a href="about.asp">REFERENCES</a></li>
</ul>
</div>
<div id = "text">
<h2>World Wide Web</h2>
</div>
</div>
CSS :
#header {
width: 97%;
height: 70px;
background: black;
position: relative;
border: 5px solid white;
margin: 20px;
}
#header:after {
content: '';
position: absolute;
top: -15px;
left: -15px;
right: -15px;
bottom: -15px;
background: #600202;
z-index: -1;
}
#header h1 {
font-family: Arial;
color: white;
text-align: center;
}
#navbar {
padding-left: 8px;
margin:5px;
}
#navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 15%;
background-color: #f1f1f1;
position: fixed;
overflow: auto;
border: 5px solid black;
border-radius: 3%;
font-family: Arial;
font-weight: bold;
}
#navbar li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
#navbar li a:hover {
background-color: #555;
color: white;
}
#navbar li a.active {
background-color: #600202;
color: white;
}
#navbar li {
text-align: center;
border-bottom: 5px solid black;
}
#navbar li:last-child {
border-bottom: none;
}
#text {
border:1px solid black;
}
여기서는 'position : absolute;'를 사용하지 말아야합니다. 여기서는 float 또는 display가 훨씬 더 효율적일 수 있습니다. –
그러나 그 위치 : 절대; 헤더 div에 대한 것이므로 그 아래 내용과 관련이 없어야합니다. 아니면 내가 틀렸어 –
네가 맞아, 내가 너무 빨리 보았다. 박스 섀도우도 사용하고이 절대적인 의사를 버려도된다. (나는 단지 내가 당신의 CSS의 일부분을 놓친 것을 발견했다.) –