我正在尝试构建一个带有侧边栏的两列布局,该侧边栏始终位于页面左侧,主要内容区域居中,当调整窗口大小时,居中的内容最终会碰到导航栏,但永远不要向左移动超过它们接触时的位置(将离开:150px)。
有人可以帮我吗?
这是CSS:
@charset "UTF-8";
/* CSS Document */
body,td,th {
font-size: 16px;
font-family: Verdana, Geneva, sans-serif;
color: #000;
}
body {
background-color: #FFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 15px;
margin-bottom: 0px;
}
#nav {
position: fixed;
top: 0px;
left: 0px;
width: 150px;
height: 10000px;
background-color: #D61D21;
text-align: right;
}
#nav a:link {
color: #FFF;
text-decoration: none;
}
#nav a:visited {
color: #FFF;
text-decoration: none;
}
#nav a:hover {
color: #FFF;
text-decoration: underline;
}
#main {
width: 810px;
height: 810px;
margin: 0px auto;
}
这是html:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Nick Passaro Designs</title>
<link href="css/index.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="nav">
<a href="index.php"><img src="assets/marklogo.jpg" width="150" height="97" border="0" alt="Nick Passaro Designs"></a>
<p><a href="portfolio.php">PORTFOLIO</a> </p>
<p><a href="logos.php">LOGOS</a> </p>
<p><a href="print.php">PRINT</a> </p>
<p><a href="web.php">WEB DESIGN</a> </p>
<p><a href="photography.php">PHOTOGRAPHY</a> </p>
<p><a href="contact.php">CONTACT</a> </p>
</div>
<div id="main">
ENTER CONTENT HERE
</div>
</body>
</html>
任何帮助是极大的赞赏!